Get a cursor for the current connection. For internal use only.

def cursor(self):
        """
        Get a cursor for the current connection. For internal use only.
        """
        cursor = self.mdr.cursor()
        with self.transaction():
            try:
                yield cursor
                if cursor.rowcount != -1:
                    self.last_row_count = cursor.rowcount
                self.last_row_id = getattr(cursor, 'lastrowid', None)
            except:
                self.last_row_count = None
                self.last_row_id = None
                _safe_close(cursor)
                raise