Changeset 234:62c163941626 in livinglogic.python.orasql

Show
Ignore:
Timestamp:
02/07/08 16:56:22 (12 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Tags:
rel-1-20
Message:

The fancy fetch methods have been renamed to :meth:xfetchone,
:meth:xfetchmany, :meth:xfetchall and :meth:xfetch. :meth:__iter__
no longer gets overwritten. New methods :meth:xexecute and
:meth:xexecutemany have been added, that support passing unicode
parameters.

Files:
4 modified

Legend:

Unmodified
Added
Removed
  • NEWS.rst

    r230 r234  
     1Changes in 1.20 (released 02/07/2008) 
     2------------------------------------- 
     3 
     4*   The fancy fetch methods have been renamed to :meth:`xfetchone`, 
     5    :meth:`xfetchmany`, :meth:`xfetchall` and :meth:`xfetch`. :meth:`__iter__` 
     6    no longer gets overwritten. New methods :meth:`xexecute` and 
     7    :meth:`xexecutemany` have been added, that support passing unicode 
     8    parameters. 
     9 
     10 
    111Changes in 1.19 (released 02/01/2008) 
    212------------------------------------- 
  • setup.py

    r228 r234  
    5656args=dict( 
    5757    name="ll-orasql", 
    58     version="1.19", 
     58    version="1.20", 
    5959    description="Utilities for working with cx_Oracle", 
    6060    long_description=descr, 
  • src/ll/orasql/__init__.py

    r222 r234  
    9999 
    100100 
    101 def _promotevalue(value, cursor, isblob): 
    102     if isinstance(value, LOB) and (cursor.readlobs is True or (isinstance(cursor.readlobs, (int, long)) and value.size() <= cursor.readlobs)): 
    103         value = value.read() 
    104     if isinstance(value, str) and cursor.unicode and cursor.connection.encoding and not isblob: 
    105         value = value.decode(cursor.connection.encoding) 
    106     return value 
    107  
    108  
    109101class Record(dict): 
    110102    """ 
     
    130122        database data. 
    131123        """ 
    132         return cls((descr[0].lower(), _promotevalue(field, cursor, descr[1] is BLOB)) for (descr, field) in itertools.izip(cursor.description, row)) 
     124        return cls((descr[0].lower(), cursor._decode(field, descr[1] in (BLOB, BINARY))) for (descr, field) in itertools.izip(cursor.description, row)) 
    133125 
    134126    def __getitem__(self, name): 
     
    215207        """ 
    216208        Create a new connection. In addition to the parameters supported by 
    217         :func:`cx_Oracle.connect` the following keyword arguments are supported. 
     209        :func:`cx_Oracle.connect` the following keyword argument is supported. 
    218210 
    219211        :var:`readlobs` : bool or integer 
     
    223215            will be returned as strings. If :var:`readlobs` is :const:`True` 
    224216            all :class:`LOB` values will be returned as strings. 
    225  
    226         :var:`unicode` : bool 
    227             If :var:`unicode` is true, strings (and :class:`CLOB` values, if 
    228             :var:`readlobs` has the appropriate value) will be returned as 
    229             :class:`unicode` objects (except for :class:`BLOB` values). Note that 
    230             strings in the national character set (and :class:`NCLOB` values) are 
    231             not supported). 
    232217        """ 
    233218        if "readlobs" in kwargs or "unicode" in kwargs: 
     
    243228        return "%s@%s" % (self.username, self.tnsentry) 
    244229 
    245     def cursor(self, readlobs=None, unicode=None): 
     230    def cursor(self, readlobs=None): 
    246231        """ 
    247232        Return a new cursor for this connection. For the meaning of 
    248         :var:`readlobs` and :var:`unicode` see :meth:`__init__`. 
    249         """ 
    250         return Cursor(self, readlobs=readlobs, unicode=unicode) 
     233        :var:`readlobs` see :meth:`__init__`. 
     234        """ 
     235        return Cursor(self, readlobs=readlobs) 
    251236 
    252237    def __repr__(self): 
     
    268253        cursor = self.cursor() 
    269254        if schema == "all": 
    270             cursor.execute("select object_type as type, count(*) as count from all_objects group by object_type") 
    271         else: 
    272             cursor.execute("select object_type as type, count(*) as count from user_objects group by object_type") 
    273         for row in cursor.fetchall(): 
     255            cursor.xexecute("select object_type as type, count(*) as count from all_objects group by object_type") 
     256        else: 
     257            cursor.xexecute("select object_type as type, count(*) as count from user_objects group by object_type") 
     258        for row in cursor.xfetchall(): 
    274259            class_ = Object.name2type.get(row.type.lower(), None) 
    275260            if class_ is not None: 
    276261                yield _AllTypes(self, class_, schema, row.count) 
    277262        if schema == "all": 
    278             cursor.execute("select object_type as type, count(*) as count from all_objects group by object_type") 
    279         else: 
    280             cursor.execute("select object_type as type, count(*) as count from user_objects group by object_type") 
    281         if schema == "all": 
    282263            cursor.execute("select count(*) as count from all_tab_privs") 
    283264        else: 
    284265            cursor.execute("select count(*) as count from user_tab_privs where owner=user") 
    285         yield _AllTypes(self, Privilege, schema, cursor.fetchone().count) 
     266        yield _AllTypes(self, Privilege, schema, cursor.fetchone()[0]) 
    286267 
    287268    def itertables(self, schema="user"): 
     
    309290        else: 
    310291            cursor.execute("select null as owner, table_name from user_tables minus select null as owner, mview_name as table_name from user_mviews") 
    311         for rec in cursor.fetchall(): 
     292        for rec in cursor.xfetchall(): 
    312293            yield Table(rec.table_name, rec.owner, self) 
    313294 
     
    334315        else: 
    335316            cursor.execute("select null as owner, constraint_name from user_constraints where constraint_type='R' order by table_name, constraint_name") 
    336         for rec in cursor.fetchall(): 
     317        for rec in cursor.xfetchall(): 
    337318            yield ForeignKey(rec.constraint_name, rec.owner, self) 
    338319 
     
    391372            # select * from all_sequences where sequence_owner=nvl(:owner, user) and sequence_name=:name 
    392373            if schema == "all": 
    393                 cursor.execute("select decode(sequence_owner, user, null, sequence_owner) as sequence_owner, sequence_name from all_sequences") 
     374                cursor.xexecute("select decode(sequence_owner, user, null, sequence_owner) as sequence_owner, sequence_name from all_sequences") 
    394375            else: 
    395                 cursor.execute("select null as sequence_owner, sequence_name from user_sequences") 
    396             for rec in cursor.fetchall(): 
     376                cursor.xexecute("select null as sequence_owner, sequence_name from user_sequences") 
     377            for rec in cursor.xfetchall(): 
    397378                for obj in do(Sequence(rec.sequence_name, rec.sequence_owner, self)): 
    398379                    yield obj 
     
    400381        def dotables(): 
    401382            if schema == "all": 
    402                 cursor.execute("select decode(owner, user, null, owner) as owner, table_name from all_tables") 
     383                cursor.xexecute("select decode(owner, user, null, owner) as owner, table_name from all_tables") 
    403384            else: 
    404                 cursor.execute("select null as owner, table_name from user_tables") 
    405             for rec in cursor.fetchall(): 
     385                cursor.xexecute("select null as owner, table_name from user_tables") 
     386            for rec in cursor.xfetchall(): 
    406387                obj = Table(rec.table_name, rec.owner, self) 
    407388                if mode == "create" or mode == "flat": 
     
    412393                    # Primary key 
    413394                    if schema == "all": 
    414                         cursor.execute("select decode(owner, user, null, owner) as owner, constraint_name from all_constraints where constraint_type='P' and owner=:owner and table_name=:name", owner=rec.owner, name=rec.table_name) 
     395                        cursor.xexecute("select decode(owner, user, null, owner) as owner, constraint_name from all_constraints where constraint_type='P' and owner=:owner and table_name=:name", owner=rec.owner, name=rec.table_name) 
    415396                    else: 
    416                         cursor.execute("select null as owner, constraint_name from user_constraints where constraint_type='P' and table_name=:name", name=rec.table_name) 
    417                     for rec2 in cursor.fetchall(): 
     397                        cursor.xexecute("select null as owner, constraint_name from user_constraints where constraint_type='P' and table_name=:name", name=rec.table_name) 
     398                    for rec2 in cursor.xfetchall(): 
    418399                        for subobj in do(PrimaryKey(rec2.constraint_name, rec2.owner, self)): 
    419400                            yield subobj 
     
    421402                    # Comments 
    422403                    if schema == "all": 
    423                         cursor.execute("select column_name from all_tab_columns where owner=:owner and table_name=:name order by column_id", owner=rec.owner, name=rec.table_name) 
     404                        cursor.xexecute("select column_name from all_tab_columns where owner=:owner and table_name=:name order by column_id", owner=rec.owner, name=rec.table_name) 
    424405                    else: 
    425                         cursor.execute("select column_name from user_tab_columns where table_name=:name order by column_id", name=rec.table_name) 
    426                     for rec2 in cursor.fetchall(): 
     406                        cursor.xexecute("select column_name from user_tab_columns where table_name=:name order by column_id", name=rec.table_name) 
     407                    for rec2 in cursor.xfetchall(): 
    427408                        # No dependency checks neccessary, but use do anyway 
    428409                        for subobj in do(Comment("%s.%s" % (rec.table_name, rec2.column_name), rec.owner, self)): 
     
    435416        def doconstraints(): 
    436417            if schema == "all": 
    437                 cursor.execute("select constraint_type, decode(owner, user, null, owner) as owner, constraint_name from all_constraints where constraint_type in ('R', 'U') order by owner, table_name, constraint_type, constraint_name") 
     418                cursor.xexecute("select constraint_type, decode(owner, user, null, owner) as owner, constraint_name from all_constraints where constraint_type in ('R', 'U') order by owner, table_name, constraint_type, constraint_name") 
    438419            else: 
    439                 cursor.execute("select constraint_type, null as owner, constraint_name from user_constraints where constraint_type in ('R', 'U') order by table_name, constraint_type, constraint_name") 
     420                cursor.xexecute("select constraint_type, null as owner, constraint_name from user_constraints where constraint_type in ('R', 'U') order by table_name, constraint_type, constraint_name") 
    440421            types = {"U": UniqueConstraint, "R": ForeignKey} 
    441             for rec in cursor.fetchall(): 
     422            for rec in cursor.xfetchall(): 
    442423                for subobj in do(types[rec.constraint_type](rec.constraint_name, rec.owner, self)): 
    443424                    yield subobj 
     
    445426        def doindexes(): 
    446427            if schema == "all": 
    447                 cursor.execute("select decode(owner, user, null, owner) as owner, index_name from all_indexes where index_type in ('NORMAL', 'FUNCTION-BASED NORMAL') order by owner, table_name, index_name") 
     428                cursor.xexecute("select decode(owner, user, null, owner) as owner, index_name from all_indexes where index_type in ('NORMAL', 'FUNCTION-BASED NORMAL') order by owner, table_name, index_name") 
    448429            else: 
    449                 cursor.execute("select null as owner, index_name from user_indexes where index_type in ('NORMAL', 'FUNCTION-BASED NORMAL') order by table_name, index_name") 
    450             for rec in cursor.fetchall(): 
     430                cursor.xexecute("select null as owner, index_name from user_indexes where index_type in ('NORMAL', 'FUNCTION-BASED NORMAL') order by table_name, index_name") 
     431            for rec in cursor.xfetchall(): 
    451432                for subobj in do(Index(rec.index_name, rec.owner, self)): 
    452433                    yield subobj 
     
    454435        def dosynonyms(): 
    455436            if schema == "all": 
    456                 cursor.execute("select decode(owner, user, null, owner) as owner, synonym_name from all_synonyms") 
     437                cursor.xexecute("select decode(owner, user, null, owner) as owner, synonym_name from all_synonyms") 
    457438            else: 
    458                 cursor.execute("select null as owner, synonym_name from user_synonyms") 
    459             for rec in cursor.fetchall(): 
     439                cursor.xexecute("select null as owner, synonym_name from user_synonyms") 
     440            for rec in cursor.xfetchall(): 
    460441                for subobj in do(Synonym(rec.synonym_name, rec.owner, self)): 
    461442                    yield subobj 
     
    463444        def doviews(): 
    464445            if schema == "all": 
    465                 cursor.execute("select decode(owner, user, null, owner) as owner, view_name from all_views") 
     446                cursor.xexecute("select decode(owner, user, null, owner) as owner, view_name from all_views") 
    466447            else: 
    467                 cursor.execute("select null as owner, view_name from user_views") 
    468             for rec in cursor.fetchall(): 
     448                cursor.xexecute("select null as owner, view_name from user_views") 
     449            for rec in cursor.xfetchall(): 
    469450                for subobj in do(View(rec.view_name, rec.owner, self)): 
    470451                    yield subobj 
     
    472453        def domviews(): 
    473454            if schema == "all": 
    474                 cursor.execute("select decode(owner, user, null, owner) as owner, mview_name from all_mviews") 
     455                cursor.xexecute("select decode(owner, user, null, owner) as owner, mview_name from all_mviews") 
    475456            else: 
    476                 cursor.execute("select null as owner, mview_name from user_mviews") 
    477             for rec in cursor.fetchall(): 
     457                cursor.xexecute("select null as owner, mview_name from user_mviews") 
     458            for rec in cursor.xfetchall(): 
    478459                for subobj in do(MaterializedView(rec.mview_name, rec.owner, self)): 
    479460                    yield subobj 
     
    482463            for type in (Function, Procedure, Package, PackageBody, Type, Trigger, JavaSource): 
    483464                if schema == "all": 
    484                     cursor.execute("select decode(owner, user, null, owner) as owner, object_name from all_objects where lower(object_type)=lower(:type)", type=type.type) 
     465                    cursor.xexecute("select decode(owner, user, null, owner) as owner, object_name from all_objects where lower(object_type)=lower(:type)", type=type.type) 
    485466                else: 
    486                     cursor.execute("select null as owner, object_name from user_objects where lower(object_type)=lower(:type)", type=type.type) 
    487                 for rec in cursor.fetchall(): 
     467                    cursor.xexecute("select null as owner, object_name from user_objects where lower(object_type)=lower(:type)", type=type.type) 
     468                for rec in cursor.xfetchall(): 
    488469                    for subobj in do(type(rec.object_name, rec.owner, self)): 
    489470                        yield subobj 
     
    522503class Cursor(Cursor): 
    523504    """ 
    524     A subclass of the cursor class in :mod:`cx_Oracle`. Database results 
    525     returned from :meth:`fetchone`, :meth:`fetchmany`, :meth:`fetchall` and 
    526     :meth:`fetch` or by iterating the cursor will be returned as 
    527     :class:`Record` objects. 
    528     """ 
    529     def __init__(self, connection, readlobs=None, unicode=None): 
     505    A subclass of the cursor class in :mod:`cx_Oracle`. A :class:`Cursor` object 
     506    provides the following additional methods: :meth:`xexecute`, 
     507    :meth:`xexecutemany`, :meth:`xfetchone`, :meth:`xfetchmany`, :meth:`xfetchall` 
     508    and :meth:`xfetch`. The "execute" methods support a unicode statement and 
     509    unicode parameters (they will be encoded in the client encoding before being 
     510    passed to the database). The "fetch" methods will return records as 
     511    :class:`Record` objects and string values and ``CLOB`` values, if the 
     512    cursors :attr:`readlobs` attribute has the appropriate value) will be 
     513    returned as :class:`unicode` objects (except for :class:`BLOB` values). 
     514    (Note that strings in the national character set (and :class:`NCLOB` values) 
     515    are not supported). 
     516    """ 
     517    def __init__(self, connection, readlobs=None): 
    530518        """ 
    531519        Return a new cursor for the connection :var:`connection`. For the meaning 
    532         of :var:`readlobs` and :var:`unicode` see :meth:`Connection.__init__. 
     520        of :var:`readlobs` see :meth:`Connection.__init__. 
    533521        """ 
    534522        super(Cursor, self).__init__(connection) 
    535         if readlobs is not None: 
    536             self.readlobs = readlobs 
    537         else: 
    538             self.readlobs = connection.readlobs 
    539         if unicode is not None: 
    540             self.unicode = unicode 
    541         else: 
    542             self.unicode = connection.unicode 
    543          
    544     def fetchone(self, type=Record): 
    545         row = super(Cursor, self).fetchone() 
     523        self.readlobs = (readlobs if readlobs is not None else connection.readlobs) 
     524 
     525    def _encode(self, value): 
     526        # Helper method that encodes :var:`value` using the client encoding (if :var:`value` is :class:`unicode`) 
     527        if isinstance(value, unicode): 
     528            return value.encode(self.connection.encoding) 
     529        return value 
     530 
     531    def _decode(self, value, isblob): 
     532        if isinstance(value, LOB) and (self.readlobs is True or (isinstance(self.readlobs, (int, long)) and value.size() <= self.readlobs)): 
     533            value = value.read() 
     534        if isinstance(value, str) and not isblob: 
     535            value = value.decode(self.connection.encoding) 
     536        return value 
     537 
     538    def xexecute(self, statement, parameters=None, **kwargs): 
     539        kwargs = dict((self._encode(key), self._encode(value)) for (key, value) in kwargs.iteritems()) 
     540        if parameters is not None: 
     541            if isinstance(parameters, dict): 
     542                parameters = dict((self._encode(key), self._encode(value)) for (key, value) in parameters.iteritems()) 
     543            else: 
     544                parameters = map(self._encode, parameters) 
     545            return self.execute(self._encode(statement), parameters, **kwargs) 
     546        return self.execute(self._encode(statement), **kwargs) 
     547 
     548    def xexecutemany(self, statement, parameters): 
     549        def _encode(value): 
     550            if isinstance(value, dict): 
     551                return dict((self._encode(key), self._encode(value)) for (key, value) in value.iteritems()) 
     552            else: 
     553                return map(self._encode, value) 
     554        return self.executemany(self._encode(statement), map(_encode, parameters)) 
     555 
     556    def xfetchone(self, type=Record): 
     557        row = self.fetchone() 
    546558        if row is not None: 
    547559            row = type.fromdata(self, row) 
    548560        return row 
    549561 
    550     def fetchmany(self, rows=0, type=Record): 
    551         sup = super(Cursor, self) 
    552         return [type.fromdata(self, row) for row in sup.fetchmany(rows)] 
    553  
    554     def fetchall(self, type=Record): 
    555         sup = super(Cursor, self) 
    556         return [type.fromdata(self, row) for row in sup.fetchall()] 
    557  
    558     def fetch(self, type=Record): 
     562    def xfetchmany(self, rows=0, type=Record): 
     563        return [type.fromdata(self, row) for row in self.fetchmany(rows)] 
     564 
     565    def xfetchall(self, type=Record): 
     566        return [type.fromdata(self, row) for row in self.fetchall()] 
     567 
     568    def xfetch(self, type=Record): 
    559569        while True: 
    560570            yield type.fromdata(self, self.next()) 
    561  
    562     def __iter__(self): 
    563         return self.fetch() 
    564571 
    565572    def __xrepr__(self, mode): 
     
    615622    def cdate(self, connection=None): 
    616623        (connection, cursor) = self.getcursor(connection) 
    617         cursor.execute("select created from all_objects where lower(object_type)=:type and object_name=:name and owner=nvl(:owner, user)", type=self.__class__.type, name=self.name, owner=self.owner) 
    618         row = cursor.fetchone() 
     624        cursor.xexecute("select created from all_objects where lower(object_type)=:type and object_name=:name and owner=nvl(:owner, user)", type=self.__class__.type, name=self.name, owner=self.owner) 
     625        row = cursor.xfetchone() 
    619626        if row is None: 
    620627            raise SQLObjectNotFoundError(self) 
     
    623630    def udate(self, connection=None): 
    624631        (connection, cursor) = self.getcursor(connection) 
    625         cursor.execute("select last_ddl_time from all_objects where lower(object_type)=:type and object_name=:name and owner=nvl(:owner, user)", type=self.__class__.type, name=self.name, owner=self.owner) 
    626         row = cursor.fetchone() 
     632        cursor.xexecute("select last_ddl_time from all_objects where lower(object_type)=:type and object_name=:name and owner=nvl(:owner, user)", type=self.__class__.type, name=self.name, owner=self.owner) 
     633        row = cursor.xfetchone() 
    627634        if row is None: 
    628635            raise SQLObjectNotFoundError(self) 
     
    637644    def createddl(self, connection=None, term=True): 
    638645        (connection, cursor) = self.getcursor(connection) 
    639         cursor.execute("select text from all_source where lower(type)=lower(:type) and owner=nvl(:owner, user) and name=:name order by line", type=self.__class__.type, owner=self.owner, name=self.name) 
    640         code = "\n".join((rec.text or "").rstrip() for rec in cursor) # sqlplus strips trailing spaces when executing SQL scripts, so we do that too 
     646        cursor.xexecute("select text from all_source where lower(type)=lower(:type) and owner=nvl(:owner, user) and name=:name order by line", type=self.__class__.type, owner=self.owner, name=self.name) 
     647        code = "\n".join((rec.text or "").rstrip() for rec in cursor.xfetch()) # sqlplus strips trailing spaces when executing SQL scripts, so we do that too 
    641648        if not code: 
    642649            raise SQLObjectNotFoundError(self) 
     
    668675 
    669676 
    670 def getname(name, owner): 
     677def getfullname(name, owner): 
    671678    parts = [] 
    672679    if owner is not None: 
     
    692699    :class:`Synonym`, :class:`View`, :class:`MaterializedView`, :class:`Library`, 
    693700    :class:`Function`, :class:`Package`, :class:`Type`, :class:`Trigger`, 
    694     :class:`JavaSource` and:class:`Column`. 
     701    :class:`JavaSource` and :class:`Column`. 
    695702    """ 
    696703    name2type = {} # maps the Oracle type name to the Python class (populated by the metaclass) 
     
    732739        return hash(self.__class__.__name__) ^ hash(self.name) ^ hash(self.owner) 
    733740 
    734     def getname(self): 
    735         return getname(self.name, self.owner) 
     741    def getfullname(self): 
     742        return getfullname(self.name, self.owner) 
    736743 
    737744    @misc.notimplemented 
     
    773780        """ 
    774781        (connection, cursor) = self.getcursor(connection) 
    775         cursor.execute("select referenced_type, decode(referenced_owner, user, null, referenced_owner) as referenced_owner, referenced_name from all_dependencies where type=upper(:type) and name=:name and owner=nvl(:owner, user) and type != 'NON-EXISTENT'", type=self.type, name=self.name, owner=self.owner) 
    776         for rec in cursor: 
     782        cursor.xexecute("select referenced_type, decode(referenced_owner, user, null, referenced_owner) as referenced_owner, referenced_name from all_dependencies where type=upper(:type) and name=:name and owner=nvl(:owner, user) and type != 'NON-EXISTENT'", type=self.type, name=self.name, owner=self.owner) 
     783        for rec in cursor.xfetchall(): 
    777784            try: 
    778785                type = Object.name2type[rec.referenced_type.lower()] 
     
    806813        """ 
    807814        (connection, cursor) = self.getcursor(connection) 
    808         cursor.execute("select type, decode(owner, user, null, owner) as owner, name from all_dependencies where referenced_type=upper(:type) and referenced_name=:name and referenced_owner=nvl(:owner, user) and type != 'NON-EXISTENT'", type=self.type, name=self.name, owner=self.owner) 
    809         for rec in cursor: 
     815        cursor.xexecute("select type, decode(owner, user, null, owner) as owner, name from all_dependencies where referenced_type=upper(:type) and referenced_name=:name and referenced_owner=nvl(:owner, user) and type != 'NON-EXISTENT'", type=self.type, name=self.name, owner=self.owner) 
     816        for rec in cursor.xfetchall(): 
    810817            try: 
    811818                type = Object.name2type[rec.type.lower()] 
     
    857864        cursor = connection.cursor() 
    858865        if schema=="all": 
    859             cursor.execute("select decode(owner, user, null, owner) as owner, object_name from all_objects where lower(object_type) = :type", type=cls.type) 
    860         else: 
    861             cursor.execute("select null as owner, object_name from user_objects where lower(object_type) = :type", type=cls.type) 
    862         return (cls(row.object_name, row.owner, connection) for row in cursor) 
     866            cursor.xexecute("select decode(owner, user, null, owner) as owner, object_name from all_objects where lower(object_type) = :type", type=cls.type) 
     867        else: 
     868            cursor.xexecute("select null as owner, object_name from user_objects where lower(object_type) = :type", type=cls.type) 
     869        return (cls(row.object_name, row.owner, connection) for row in cursor.xfetch()) 
    863870 
    864871    def __iter__(self): 
     
    902909    def _createddl(self, connection, term, copyvalue): 
    903910        (connection, cursor) = self.getcursor(connection) 
    904         cursor.execute("select * from all_sequences where sequence_owner=nvl(:owner, user) and sequence_name=:name", owner=self.owner, name=self.name) 
    905         rec = cursor.fetchone() 
     911        cursor.xexecute("select * from all_sequences where sequence_owner=nvl(:owner, user) and sequence_name=:name", owner=self.owner, name=self.name) 
     912        rec = cursor.xfetchone() 
    906913        if rec is None: 
    907914            raise SQLObjectNotFoundError(self) 
    908         code  = "create sequence %s\n" % self.getname() 
     915        code  = "create sequence %s\n" % self.getfullname() 
    909916        code += "\tincrement by %d\n" % rec.increment_by 
    910917        if copyvalue: 
     
    936943 
    937944    def dropddl(self, connection=None, term=True): 
    938         code = "drop sequence %s" % self.getname() 
     945        code = "drop sequence %s" % self.getfullname() 
    939946        if term: 
    940947            code += ";\n" 
     
    10071014        if self.ismview(connection): 
    10081015            return "" 
    1009         cursor.execute("select * from all_tab_columns where owner=nvl(:owner, user) and table_name=:name order by column_id asc", owner=self.owner, name=self.name) 
    1010         recs = cursor.fetchall() 
     1016        cursor.xexecute("select * from all_tab_columns where owner=nvl(:owner, user) and table_name=:name order by column_id asc", owner=self.owner, name=self.name) 
     1017        recs = cursor.xfetchall() 
    10111018        if not recs: 
    10121019            raise SQLObjectNotFoundError(self) 
    1013         code = ["create table %s\n(\n" % self.getname()] 
     1020        code = ["create table %s\n(\n" % self.getfullname()] 
    10141021        for (i, rec) in enumerate(recs): 
    10151022            if i: 
     
    10301037        if self.ismview(connection): 
    10311038            return "" 
    1032         code = "drop table %s" % self.getname() 
     1039        code = "drop table %s" % self.getfullname() 
    10331040        if term: 
    10341041            code += ";\n" 
     
    10431050        """ 
    10441051        (connection, cursor) = self.getcursor(connection) 
    1045         cursor.execute("select mview_name from all_mviews where owner=nvl(:owner, user) and mview_name=:name", owner=self.owner, name=self.name) 
    1046         rec = cursor.fetchone() 
     1052        cursor.xexecute("select mview_name from all_mviews where owner=nvl(:owner, user) and mview_name=:name", owner=self.owner, name=self.name) 
     1053        rec = cursor.xfetchone() 
    10471054        if rec is not None: 
    10481055            rec = MaterializedView(self.name, self.owner, connection) 
     
    10591066        cursor = connection.cursor() 
    10601067        if schema == "all": 
    1061             cursor.execute("select decode(owner, user, null, owner) as owner, table_name from all_tables") 
    1062         else: 
    1063             cursor.execute("select null as owner, table_name from user_tables") 
    1064         return (cls(row.table_name, row.owner, connection=connection) for row in cursor) 
     1068            cursor.xexecute("select decode(owner, user, null, owner) as owner, table_name from all_tables") 
     1069        else: 
     1070            cursor.xexecute("select null as owner, table_name from user_tables") 
     1071        return (cls(row.table_name, row.owner, connection=connection) for row in cursor.xfetch()) 
    10651072 
    10661073    def itercolumns(self, connection=None): 
     
    10691076        """ 
    10701077        (connection, cursor) = self.getcursor(connection) 
    1071         cursor.execute("select column_name from all_tab_columns where owner=nvl(:owner, user) and table_name=:name order by column_id", owner=self.owner, name=self.name) 
    1072  
    1073         for rec in cursor.fetchall(): 
     1078        cursor.xexecute("select column_name from all_tab_columns where owner=nvl(:owner, user) and table_name=:name order by column_id", owner=self.owner, name=self.name) 
     1079 
     1080        for rec in cursor.xfetchall(): 
    10741081            yield Column("%s.%s" % (self.name, rec.column_name), self.owner, connection) 
    10751082 
     
    10791086        """ 
    10801087        (connection, cursor) = self.getcursor(connection) 
    1081         query = "select * from %s" % self.getname() 
    1082         cursor.execute(query) 
    1083         return iter(cursor) 
     1088        query = "select * from %s" % self.getfullname() 
     1089        cursor.xexecute(query) 
     1090        return cursor.xfetch() 
    10841091 
    10851092    def itercomments(self, connection=None): 
     
    10881095        """ 
    10891096        (connection, cursor) = self.getcursor(connection) 
    1090         cursor.execute("select column_name from all_tab_columns where owner=nvl(:owner, user) and table_name=:name order by column_id", owner=self.owner, name=self.name) 
    1091         for rec in cursor.fetchall(): 
     1097        cursor.xexecute("select column_name from all_tab_columns where owner=nvl(:owner, user) and table_name=:name order by column_id", owner=self.owner, name=self.name) 
     1098        for rec in cursor.xfetchall(): 
    10921099            yield Comment("%s.%s" % (self.name, rec.column_name), self.owner, connection) 
    10931100 
     
    10981105        (connection, cursor) = self.getcursor(connection) 
    10991106        # Primary and unique key(s) 
    1100         cursor.execute("select decode(owner, user, null, owner) as owner, constraint_type, constraint_name from all_constraints where constraint_type in ('P', 'U', 'R') and owner=nvl(:owner, user) and table_name=:name", owner=self.owner, name=self.name) 
     1107        cursor.xexecute("select decode(owner, user, null, owner) as owner, constraint_type, constraint_name from all_constraints where constraint_type in ('P', 'U', 'R') and owner=nvl(:owner, user) and table_name=:name", owner=self.owner, name=self.name) 
    11011108        types = {"P": PrimaryKey, "U": UniqueConstraint, "R": ForeignKey} 
    1102         for rec in cursor: 
     1109        for rec in cursor.xfetchall(): 
    11031110            yield types[rec.constraint_type](rec.constraint_name, rec.owner, connection) 
    11041111 
     
    11471154    def createddl(self, connection=None, term=True): 
    11481155        (connection, cursor) = self.getcursor(connection) 
    1149         cursor.execute("select decode(owner, user, null, owner) as owner, constraint_name, table_name, r_owner, r_constraint_name from all_constraints where constraint_type='P' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
    1150         rec2 = cursor.fetchone() 
     1156        cursor.xexecute("select decode(owner, user, null, owner) as owner, constraint_name, table_name, r_owner, r_constraint_name from all_constraints where constraint_type='P' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
     1157        rec2 = cursor.xfetchone() 
    11511158        if rec2 is None: 
    11521159            raise SQLObjectNotFoundError(self) 
    1153         cursor.execute("select column_name from all_cons_columns where owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
    1154         tablename = getname(rec2.table_name, rec2.owner) 
    1155         pkname = getname(self.name, None) 
    1156         code = "alter table %s add constraint %s primary key(%s)" % (tablename, pkname, ", ".join(r.column_name for r in cursor)) 
     1160        cursor.xexecute("select column_name from all_cons_columns where owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
     1161        tablename = getfullname(rec2.table_name, rec2.owner) 
     1162        pkname = getfullname(self.name, None) 
     1163        code = "alter table %s add constraint %s primary key(%s)" % (tablename, pkname, ", ".join(r.column_name for r in cursor.xfetch())) 
    11571164        if term: 
    11581165            code += ";\n" 
     
    11631170    def dropddl(self, connection=None, term=True): 
    11641171        (connection, cursor) = self.getcursor(connection) 
    1165         cursor.execute("select decode(owner, user, null, owner) as owner, table_name from all_constraints where owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
    1166         rec = cursor.fetchone() 
    1167         tablename = getname(rec.table_name, rec.owner) 
    1168         pkname = getname(self.name, None) 
     1172        cursor.xexecute("select decode(owner, user, null, owner) as owner, table_name from all_constraints where owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
     1173        rec = cursor.xfetchone() 
     1174        tablename = getfullname(rec.table_name, rec.owner) 
     1175        pkname = getfullname(self.name, None) 
    11691176        code = "alter table %s drop constraint %s" % (tablename, pkname) 
    11701177        if term: 
     
    11761183    def cdate(self, connection=None): 
    11771184        (connection, cursor) = self.getcursor(connection) 
    1178         cursor.execute("select last_change from all_constraints where constraint_type='P' and constraint_name=:name and owner=nvl(:owner, user)", name=self.name, owner=self.owner) 
     1185        cursor.xexecute("select last_change from all_constraints where constraint_type='P' and constraint_name=:name and owner=nvl(:owner, user)", name=self.name, owner=self.owner) 
    11791186        row = cursor.fetchone() 
    11801187        if row is None: 
     
    11841191    def udate(self, connection=None): 
    11851192        (connection, cursor) = self.getcursor(connection) 
    1186         cursor.execute("select last_change from all_constraints where constraint_type='P' and constraint_name=:name and owner=nvl(:owner, user)", name=self.name, owner=self.owner) 
     1193        cursor.xexecute("select last_change from all_constraints where constraint_type='P' and constraint_name=:name and owner=nvl(:owner, user)", name=self.name, owner=self.owner) 
    11871194        row = cursor.fetchone() 
    11881195        if row is None: 
    11891196            raise SQLObjectNotFoundError(self) 
    1190         return row.last_change 
     1197        return row[0] 
    11911198 
    11921199    def iterreferencedby(self, connection=None): 
    11931200        (connection, cursor) = self.getcursor(connection) 
    1194         cursor.execute("select decode(owner, user, null, owner) as owner, constraint_name from all_constraints where constraint_type='R' and r_owner=nvl(:owner, user) and r_constraint_name=:name", owner=self.owner, name=self.name) 
    1195         for rec in cursor.fetchall(): 
     1201        cursor.xexecute("select decode(owner, user, null, owner) as owner, constraint_name from all_constraints where constraint_type='R' and r_owner=nvl(:owner, user) and r_constraint_name=:name", owner=self.owner, name=self.name) 
     1202        for rec in cursor.xfetchall(): 
    11961203            yield ForeignKey(rec.constraint_name, rec.owner, connection) 
    11971204 
    1198         cursor.execute("select decode(owner, user, null, owner) as owner, index_name from all_indexes where owner=nvl(:owner, user) and index_name=:name", owner=self.owner, name=self.name) 
    1199         rec = cursor.fetchone() # Ist there an index for this constraint? 
     1205        cursor.xexecute("select decode(owner, user, null, owner) as owner, index_name from all_indexes where owner=nvl(:owner, user) and index_name=:name", owner=self.owner, name=self.name) 
     1206        rec = cursor.xfetchone() # Is there an index for this constraint? 
    12001207        if rec is not None: 
    12011208            yield Index(rec.index_name, rec.owner, connection) 
     
    12031210    def iterreferences(self, connection=None): 
    12041211        (connection, cursor) = self.getcursor(connection) 
    1205         cursor.execute("select decode(owner, user, null, owner) as owner, table_name from all_constraints where constraint_type='P' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
    1206         for rec in cursor.fetchall(): 
     1212        cursor.xexecute("select decode(owner, user, null, owner) as owner, table_name from all_constraints where constraint_type='P' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
     1213        for rec in cursor.xfetchall(): 
    12071214            yield Table(rec.table_name, rec.owner, connection) 
    12081215 
     
    12121219        """ 
    12131220        (connection, cursor) = self.getcursor(connection) 
    1214         cursor.execute("select table_name from all_constraints where constraint_type='P' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
    1215         rec = cursor.fetchone() 
     1221        cursor.xexecute("select table_name from all_constraints where constraint_type='P' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
     1222        rec = cursor.xfetchone() 
    12161223        return Table(rec.table_name, self.owner, connection) 
    12171224 
     
    12321239        (connection, cursor) = self.getcursor(connection) 
    12331240        tcname = self.name.split(".") 
    1234         cursor.execute("select comments from all_col_comments where owner=nvl(:owner, user) and table_name=:tname and column_name=:cname", owner=self.owner, tname=tcname[0], cname=tcname[1]) 
    1235         row = cursor.fetchone() 
     1241        cursor.xexecute("select comments from all_col_comments where owner=nvl(:owner, user) and table_name=:tname and column_name=:cname", owner=self.owner, tname=tcname[0], cname=tcname[1]) 
     1242        row = cursor.xfetchone() 
    12361243        if row is None: 
    12371244            raise SQLObjectNotFoundError(self) 
    12381245 
    1239         name = self.getname() 
     1246        name = self.getfullname() 
    12401247        if row.comments: 
    12411248            code = "comment on column %s is %s" % (name, formatstring(row.comments, latin1=True)) 
     
    12761283        (connection, cursor) = self.getcursor(connection) 
    12771284        # Add constraint_type to the query, so we don't pick up another constraint by accident 
    1278         cursor.execute("select decode(r_owner, user, null, r_owner) as r_owner, r_constraint_name, table_name from all_constraints where constraint_type='R' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
    1279         rec = cursor.fetchone() 
     1285        cursor.xexecute("select decode(r_owner, user, null, r_owner) as r_owner, r_constraint_name, table_name from all_constraints where constraint_type='R' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
     1286        rec = cursor.xfetchone() 
    12801287        if rec is None: 
    12811288            raise SQLObjectNotFoundError(self) 
    1282         cursor.execute("select column_name from all_cons_columns where owner=nvl(:owner, user) and constraint_name=:name order by position", owner=self.owner, name=self.name) 
    1283         fields1 = ", ".join(r.column_name for r in cursor) 
    1284         cursor.execute("select table_name, column_name from all_cons_columns where owner=nvl(:owner, user) and constraint_name=:name order by position", owner=rec.r_owner, name=rec.r_constraint_name) 
    1285         fields2 = ", ".join("%s(%s)" % (getname(r.table_name, rec.r_owner), r.column_name) for r in cursor) 
    1286         tablename = getname(rec.table_name, self.owner) 
    1287         fkname = getname(self.name, None) 
     1289        cursor.xexecute("select column_name from all_cons_columns where owner=nvl(:owner, user) and constraint_name=:name order by position", owner=self.owner, name=self.name) 
     1290        fields1 = ", ".join(r.column_name for r in cursor.xfetch()) 
     1291        cursor.xexecute("select table_name, column_name from all_cons_columns where owner=nvl(:owner, user) and constraint_name=:name order by position", owner=rec.r_owner, name=rec.r_constraint_name) 
     1292        fields2 = ", ".join("%s(%s)" % (getfullname(r.table_name, rec.r_owner), r.column_name) for r in cursor.xfetch()) 
     1293        tablename = getfullname(rec.table_name, self.owner) 
     1294        fkname = getfullname(self.name, None) 
    12881295        code = "alter table %s add constraint %s foreign key (%s) references %s" % (tablename, fkname, fields1, fields2) 
    12891296        if term: 
     
    12951302    def _ddl(self, connection, cmd, term): 
    12961303        (connection, cursor) = self.getcursor(connection) 
    1297         cursor.execute("select table_name from all_constraints where owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
    1298         rec = cursor.fetchone() 
     1304        cursor.xexecute("select table_name from all_constraints where owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
     1305        rec = cursor.xfetchone() 
    12991306        if rec is None: 
    13001307            raise SQLObjectNotFoundError(self) 
    1301         tablename = getname(rec.table_name, self.owner) 
    1302         fkname = getname(self.name, None) 
     1308        tablename = getfullname(rec.table_name, self.owner) 
     1309        fkname = getfullname(self.name, None) 
    13031310        code = "alter table %s %s constraint %s" % (tablename, cmd, fkname) 
    13041311        if term: 
     
    13191326    def cdate(self, connection=None): 
    13201327        (connection, cursor) = self.getcursor(connection) 
    1321         cursor.execute("select last_change from all_constraints where constraint_type='R' and constraint_name=:name and owner=nvl(:owner, user)", name=self.name, owner=self.owner) 
     1328        cursor.xexecute("select last_change from all_constraints where constraint_type='R' and constraint_name=:name and owner=nvl(:owner, user)", name=self.name, owner=self.owner) 
    13221329        row = cursor.fetchone() 
    13231330        if row is None: 
     
    13271334    def udate(self, connection=None): 
    13281335        (connection, cursor) = self.getcursor(connection) 
    1329         cursor.execute("select last_change from all_constraints where constraint_type='R' and constraint_name=:name and owner=nvl(:owner, user)", name=self.name, owner=self.owner) 
     1336        cursor.xexecute("select last_change from all_constraints where constraint_type='R' and constraint_name=:name and owner=nvl(:owner, user)", name=self.name, owner=self.owner) 
    13301337        row = cursor.fetchone() 
    13311338        if row is None: 
    13321339            raise SQLObjectNotFoundError(self) 
    1333         return row.last_change 
     1340        return row[0] 
    13341341 
    13351342    def iterreferencedby(self, connection=None): 
     
    13471354        """ 
    13481355        (connection, cursor) = self.getcursor(connection) 
    1349         cursor.execute("select table_name from all_constraints where constraint_type='R' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
     1356        cursor.xexecute("select table_name from all_constraints where constraint_type='R' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
     1357        rec = cursor.xfetchone() 
     1358        return Table(rec.table_name, self.owner, connection) 
     1359 
     1360    def pk(self, connection=None): 
     1361        """ 
     1362        Return the primary key referenced by :var:`self`. 
     1363        """ 
     1364        (connection, cursor) = self.getcursor(connection) 
     1365        cursor.xexecute("select decode(r_owner, user, null, r_owner) as r_owner, r_constraint_name from all_constraints where constraint_type='R' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
     1366        rec = cursor.xfetchone() 
     1367        return PrimaryKey(rec.r_constraint_name, rec.r_owner, connection) 
     1368 
     1369    def isenabled(self, connection=None): 
     1370        """ 
     1371        Return whether this constraint is enabled. 
     1372        """ 
     1373        (connection, cursor) = self.getcursor(connection) 
     1374        cursor.xexecute("select status from all_constraints where constraint_type='R' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
    13501375        rec = cursor.fetchone() 
    1351         return Table(rec.table_name, self.owner, connection) 
    1352  
    1353     def pk(self, connection=None): 
    1354         """ 
    1355         Return the primary key referenced by :var:`self`. 
    1356         """ 
    1357         (connection, cursor) = self.getcursor(connection) 
    1358         cursor.execute("select decode(r_owner, user, null, r_owner) as r_owner, r_constraint_name from all_constraints where constraint_type='R' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
    1359         rec = cursor.fetchone() 
    1360         return PrimaryKey(rec.r_constraint_name, rec.r_owner, connection) 
    1361  
    1362     def isenabled(self, connection=None): 
    1363         """ 
    1364         Return whether this constraint is enabled. 
    1365         """ 
    1366         (connection, cursor) = self.getcursor(connection) 
    1367         cursor.execute("select status from all_constraints where constraint_type='R' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
    1368         rec = cursor.fetchone() 
    1369         return rec.status == "ENABLED" 
     1376        return rec[0] == "ENABLED" 
    13701377 
    13711378    def __xattrs__(self, mode="default"): 
     
    13871394        if self.isconstraint(connection): 
    13881395            return "" 
    1389         cursor.execute("select index_name, table_name, uniqueness from all_indexes where table_owner=nvl(:owner, user) and index_name=:name", owner=self.owner, name=self.name) 
    1390         rec = cursor.fetchone() 
     1396        cursor.xexecute("select index_name, table_name, uniqueness from all_indexes where table_owner=nvl(:owner, user) and index_name=:name", owner=self.owner, name=self.name) 
     1397        rec = cursor.xfetchone() 
    13911398        if rec is None: 
    13921399            raise SQLObjectNotFoundError(self) 
    1393         tablename = getname(rec.table_name, self.owner) 
    1394         indexname = self.getname() 
     1400        tablename = getfullname(rec.table_name, self.owner) 
     1401        indexname = self.getfullname() 
    13951402        if rec.uniqueness == "UNIQUE": 
    13961403            unique = " unique" 
    13971404        else: 
    13981405            unique = "" 
    1399         cursor.execute("select aie.column_expression, aic.column_name from all_ind_columns aic, all_ind_expressions aie where aic.table_owner=aie.table_owner(+) and aic.index_name=aie.index_name(+) and aic.column_position=aie.column_position(+) and aic.table_owner=nvl(:owner, user) and aic.index_name=:name order by aic.column_position", owner=self.owner, name=self.name) 
    1400         code = "create%s index %s on %s (%s)" % (unique, indexname, tablename, ", ".join(r.column_expression or r.column_name for r in cursor)) 
     1406        cursor.xexecute("select aie.column_expression, aic.column_name from all_ind_columns aic, all_ind_expressions aie where aic.table_owner=aie.table_owner(+) and aic.index_name=aie.index_name(+) and aic.column_position=aie.column_position(+) and aic.table_owner=nvl(:owner, user) and aic.index_name=:name order by aic.column_position", owner=self.owner, name=self.name) 
     1407        code = "create%s index %s on %s (%s)" % (unique, indexname, tablename, ", ".join(r.column_expression or r.column_name for r in cursor.xfetch())) 
    14011408        if term: 
    14021409            code += ";\n" 
     
    14081415        if self.isconstraint(connection): 
    14091416            return "" 
    1410         code = "drop index %s" % getname(self.name, self.owner) 
     1417        code = "drop index %s" % getfullname(self.name, self.owner) 
    14111418        if term: 
    14121419            code += ";\n" 
     
    14211428        """ 
    14221429        (connection, cursor) = self.getcursor(connection) 
    1423         cursor.execute("select constraint_type from all_constraints where owner=nvl(:owner, user) and constraint_name=:name and constraint_type in ('U', 'P')", owner=self.owner, name=self.name) 
    1424         rec = cursor.fetchone() 
     1430        cursor.xexecute("select constraint_type from all_constraints where owner=nvl(:owner, user) and constraint_name=:name and constraint_type in ('U', 'P')", owner=self.owner, name=self.name) 
     1431        rec = cursor.xfetchone() 
    14251432        if rec is not None: 
    14261433            rec = {"U": UniqueConstraint, "P": PrimaryKey}[rec.constraint_type](self.name, self.owner, connection) 
     
    14471454        """ 
    14481455        (connection, cursor) = self.getcursor(connection) 
    1449         cursor.execute("select table_name from all_indexes where table_owner=nvl(:owner, user) and index_name=:name", owner=self.owner, name=self.name) 
    1450         rec = cursor.fetchone() 
     1456        cursor.xexecute("select table_name from all_indexes where table_owner=nvl(:owner, user) and index_name=:name", owner=self.owner, name=self.name) 
     1457        rec = cursor.xfetchone() 
    14511458        return Table(rec.table_name, self.owner, connection) 
    14521459 
     
    14681475        (connection, cursor) = self.getcursor(connection) 
    14691476        # Add constraint_type to the query, so we don't pick up another constraint by accident 
    1470         cursor.execute("select table_name from all_constraints where constraint_type='U' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
    1471         rec = cursor.fetchone() 
     1477        cursor.xexecute("select table_name from all_constraints where constraint_type='U' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
     1478        rec = cursor.xfetchone() 
    14721479        if rec is None: 
    14731480            raise SQLObjectNotFoundError(self) 
    1474         tablename = getname(rec.table_name, self.owner) 
    1475         uniquename = getname(self.name, None) 
    1476         cursor.execute("select column_name from all_cons_columns where owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
    1477         code = "alter table %s add constraint %s unique(%s)" % (tablename, uniquename, ", ".join(r.column_name for r in cursor)) 
     1481        tablename = getfullname(rec.table_name, self.owner) 
     1482        uniquename = getfullname(self.name, None) 
     1483        cursor.xexecute("select column_name from all_cons_columns where owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
     1484        code = "alter table %s add constraint %s unique(%s)" % (tablename, uniquename, ", ".join(r.column_name for r in cursor.xfetch())) 
    14781485        if term: 
    14791486            code += ";\n" 
     
    14841491    def dropddl(self, connection=None, term=True): 
    14851492        (connection, cursor) = self.getcursor(connection) 
    1486         cursor.execute("select table_name from all_constraints where constraint_type='U' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
    1487         rec = cursor.fetchone() 
     1493        cursor.xexecute("select table_name from all_constraints where constraint_type='U' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
     1494        rec = cursor.xfetchone() 
    14881495        if rec is None: 
    14891496            raise SQLObjectNotFoundError(self) 
    1490         tablename = getname(rec.table_name, self.owner) 
    1491         uniquename = getname(self.name, None) 
     1497        tablename = getfullname(rec.table_name, self.owner) 
     1498        uniquename = getfullname(self.name, None) 
    14921499        code = "alter table %s drop constraint %s" % (tablename, uniquename) 
    14931500        if term: 
     
    14991506    def cdate(self, connection=None): 
    15001507        (connection, cursor) = self.getcursor(connection) 
    1501         cursor.execute("select last_change from all_constraints where constraint_type='U' and constraint_name=:name and owner=nvl(:owner, user)", name=self.name, owner=self.owner) 
     1508        cursor.xexecute("select last_change from all_constraints where constraint_type='U' and constraint_name=:name and owner=nvl(:owner, user)", name=self.name, owner=self.owner) 
    15021509        row = cursor.fetchone() 
    15031510        if row is None: 
     
    15071514    def udate(self, connection=None): 
    15081515        (connection, cursor) = self.getcursor(connection) 
    1509         cursor.execute("select last_change from all_constraints where constraint_type='U' and constraint_name=:name and owner=nvl(:owner, user)", name=self.name, owner=self.owner) 
     1516        cursor.xexecute("select last_change from all_constraints where constraint_type='U' and constraint_name=:name and owner=nvl(:owner, user)", name=self.name, owner=self.owner) 
    15101517        row = cursor.fetchone() 
    15111518        if row is None: 
    15121519            raise SQLObjectNotFoundError(self) 
    1513         return row.last_change 
     1520        return row[0] 
    15141521 
    15151522    def iterreferencedby(self, connection=None): 
    15161523        (connection, cursor) = self.getcursor(connection) 
    1517         cursor.execute("select decode(owner, user, null, owner) as owner, constraint_name from all_constraints where constraint_type='R' and r_owner=nvl(:owner, user) and r_constraint_name=:name", owner=self.owner, name=self.name) 
    1518         for rec in cursor: 
     1524        cursor.xexecute("select decode(owner, user, null, owner) as owner, constraint_name from all_constraints where constraint_type='R' and r_owner=nvl(:owner, user) and r_constraint_name=:name", owner=self.owner, name=self.name) 
     1525        for rec in cursor.xfetchall(): 
    15191526            yield ForeignKey(rec.constraint_name, rec.owner, connection) 
    15201527 
    1521         cursor.execute("select decode(owner, user, null, owner) as owner, index_name from all_indexes where owner=nvl(:owner, user) and index_name=:name", owner=self.owner, name=self.name) 
    1522         rec = cursor.fetchone() # Ist there an index for this constraint? 
     1528        cursor.xexecute("select decode(owner, user, null, owner) as owner, index_name from all_indexes where owner=nvl(:owner, user) and index_name=:name", owner=self.owner, name=self.name) 
     1529        rec = cursor.xfetchone() # Ist there an index for this constraint? 
    15231530        if rec is not None: 
    15241531            yield Index(rec.index_name, rec.owner, connection) 
     
    15261533    def iterreferences(self, connection=None): 
    15271534        (connection, cursor) = self.getcursor(connection) 
    1528         cursor.execute("select decode(owner, user, null, owner) as owner, table_name from all_constraints where constraint_type='U' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
    1529         for rec in cursor.fetchall(): 
     1535        cursor.xexecute("select decode(owner, user, null, owner) as owner, table_name from all_constraints where constraint_type='U' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
     1536        for rec in cursor.xfetchall(): 
    15301537            yield Table(rec.table_name, rec.owner, connection) 
    15311538 
     
    15351542        """ 
    15361543        (connection, cursor) = self.getcursor(connection) 
    1537         cursor.execute("select table_name from all_constraints where constraint_type='U' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
    1538         rec = cursor.fetchone() 
     1544        cursor.xexecute("select table_name from all_constraints where constraint_type='U' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name) 
     1545        rec = cursor.xfetchone() 
    15391546        return Table(rec.table_name, self.owner, connection) 
    15401547 
     
    15541561    def createddl(self, connection=None, term=True): 
    15551562        (connection, cursor) = self.getcursor(connection) 
    1556         cursor.execute("select table_owner, table_name, db_link from all_synonyms where owner=nvl(:owner, user) and synonym_name=:name", owner=self.owner, name=self.name) 
    1557         rec = cursor.fetchone() 
     1563        cursor.xexecute("select table_owner, table_name, db_link from all_synonyms where owner=nvl(:owner, user) and synonym_name=:name", owner=self.owner, name=self.name) 
     1564        rec = cursor.xfetchone() 
    15581565        if rec is None: 
    15591566            raise SQLObjectNotFoundError(self) 
     
    15641571        else: 
    15651572            public = "" 
    1566         name = getname(self.name, owner) 
    1567         name2 = getname(rec.table_name, rec.table_owner) 
     1573        name = getfullname(self.name, owner) 
     1574        name2 = getfullname(rec.table_name, rec.table_owner) 
    15681575        code = "create or replace %ssynonym %s for %s" % (public, name, name2) 
    15691576        if rec.db_link is not None: 
     
    15821589        else: 
    15831590            public = "" 
    1584         name = getname(self.name, owner) 
     1591        name = getfullname(self.name, owner) 
    15851592        code = "drop %ssynonym %s" % (public, name) 
    15861593        if term: 
     
    16101617    def createddl(self, connection=None, term=True): 
    16111618        (connection, cursor) = self.getcursor(connection) 
    1612         cursor.execute("select text from all_views where owner=nvl(:owner, user) and view_name=:name", owner=self.owner, name=self.name) 
    1613         rec = cursor.fetchone() 
     1619        cursor.xexecute("select text from all_views where owner=nvl(:owner, user) and view_name=:name", owner=self.owner, name=self.name) 
     1620        rec = cursor.xfetchone() 
    16141621        if rec is None: 
    16151622            raise SQLObjectNotFoundError(self) 
    16161623        code = "\n".join(line.rstrip() for line in rec.text.strip().splitlines()) # Strip trailing whitespace 
    1617         code = "create or replace view %s as\n\t%s" % (self.getname(), code) 
     1624        code = "create or replace view %s as\n\t%s" % (self.getfullname(), code) 
    16181625        if term: 
    16191626            code += "\n/\n" 
     
    16231630 
    16241631    def dropddl(self, connection=None, term=True): 
    1625         code = "drop view %s" % self.getname() 
     1632        code = "drop view %s" % self.getfullname() 
    16261633        if term: 
    16271634            code += ";\n" 
     
    16321639    def iterrecords(self, connection=None): 
    16331640        (connection, cursor) = self.getcursor(connection) 
    1634         query = "select * from %s" % self.getname() 
    1635         cursor.execute(query) 
    1636         return iter(cursor) 
     1641        query = "select * from %s" % self.getfullname() 
     1642        cursor.xexecute(query) 
     1643        return cursor.xfetch() 
    16371644 
    16381645 
     
    16451652    def createddl(self, connection=None, term=True): 
    16461653        (connection, cursor) = self.getcursor(connection) 
    1647         cursor.execute("select * from all_mviews where owner=nvl(:owner, user) and mview_name=:name", owner=self.owner, name=self.name) 
    1648         rec = cursor.fetchone() 
     1654        cursor.xexecute("select * from all_mviews where owner=nvl(:owner, user) and mview_name=:name", owner=self.owner, name=self.name) 
     1655        rec = cursor.xfetchone() 
    16491656        if rec is None: 
    16501657            raise SQLObjectNotFoundError(self) 
    16511658        code = "\n".join(line.rstrip() for line in rec.query.strip().splitlines()) # Strip trailing whitespace 
    1652         code = "create materialized view %s\nrefresh %s on %s as\n\t%s" % (self.getname(), rec.refresh_method, rec.refresh_mode, code) 
     1659        code = "create materialized view %s\nrefresh %s on %s as\n\t%s" % (self.getfullname(), rec.refresh_method, rec.refresh_mode, code) 
    16531660        if term: 
    16541661            code += "\n/\n" 
     
    16581665 
    16591666    def dropddl(self, connection=None, term=True): 
    1660         code = "drop materialized view %s" % self.getname() 
     1667        code = "drop materialized view %s" % self.getfullname() 
    16611668        if term: 
    16621669            code += ";\n" 
     
    16841691    def createddl(self, connection=None, term=True): 
    16851692        (connection, cursor) = self.getcursor(connection) 
    1686         cursor.execute("select file_spec from all_libraries where owner=nvl(:owner, user) and library_name=:name", owner=self.owner, name=self.name) 
    1687         rec = cursor.fetchone() 
     1693        cursor.xexecute("select file_spec from all_libraries where owner=nvl(:owner, user) and library_name=:name", owner=self.owner, name=self.name) 
     1694        rec = cursor.xfetchone() 
    16881695        if rec is None: 
    16891696            raise SQLObjectNotFoundError(self) 
    1690         return "create or replace library %s as %r" % (self.getname(), rec.file_spec) 
     1697        return "create or replace library %s as %r" % (self.getfullname(), rec.file_spec) 
    16911698        if term: 
    16921699            code += ";\n" 
     
    16961703 
    16971704    def dropddl(self, connection=None, term=True): 
    1698         code = "drop library %s" % self.getname() 
     1705        code = "drop library %s" % self.getfullname() 
    16991706        if term: 
    17001707            code += ";\n" 
     
    17441751    def _calcargs(self, cursor): 
    17451752        if self._argsbypos is None: 
    1746             cursor.execute("select object_id from all_objects where owner=nvl(:owner, user) and lower(object_name)=lower(:name) and object_type=:type", owner=self.owner, name=self.name, type=self.type.upper()) 
     1753            cursor.xexecute("select object_id from all_objects where owner=nvl(:owner, user) and lower(object_name)=lower(:name) and object_type=:type", owner=self.owner, name=self.name, type=self.type.upper()) 
    17471754            if cursor.fetchone() is None: 
    17481755                raise SQLObjectNotFoundError(self) 
    17491756            self._argsbypos = [] 
    17501757            self._argsbyname = {} 
    1751             cursor.execute("select lower(argument_name) as name, lower(in_out) as in_out, lower(data_type) as datatype from all_arguments where owner=nvl(:owner, user) and lower(object_name)=lower(:name) and data_level=0 order by sequence", owner=self.owner, name=self.name) 
     1758            cursor.xexecute("select lower(argument_name) as name, lower(in_out) as in_out, lower(data_type) as datatype from all_arguments where owner=nvl(:owner, user) and lower(object_name)=lower(:name) and data_level=0 order by sequence", owner=self.owner, name=self.name) 
    17521759            i = 0 # argument position (skip return value) 
    1753             for record in cursor: 
     1760            for record in cursor.xfetch(): 
    17541761                arginfo = Argument(record.name, i, record.datatype, "in" in record.in_out, "out" in record.in_out) 
    17551762                if record.name is None: # this is the return value 
     
    17771784                if realargs[arginfo.position] is not _default: 
    17781785                    raise TypeError("duplicate argument for %r: %s" % (self, key)) 
    1779             if isinstance(value, unicode) and cursor.connection.encoding is not None: 
    1780                 value = value.encode(cursor.connection.encoding) 
    1781             realargs[arginfo.position] = value 
     1786            realargs[arginfo.position] = cursor._encode(value) 
    17821787 
    17831788        # Replace out parameters (and strings that are longer than the allowed 
    1784         # maximum) with variables; replace unspecified parameters with None 
     1789        # maximum) with variables; replace unspecified parameters with :const:`None` 
    17851790        for arginfo in self._argsbypos: 
    17861791            realarg = realargs[arginfo.position] 
     
    18391844        else: 
    18401845            name = "%s.%s" % (self.owner, self.name) 
    1841  
    1842         return Record((self._argsbypos[i].name, _promotevalue(value, cursor, self._argsbypos[i].datatype == "blob")) for (i, value) in enumerate(cursor.callproc(name, realargs))) 
     1846        name = cursor._encode(name) 
     1847 
     1848        return Record((self._argsbypos[i].name, cursor._decode(value, self._argsbypos[i].datatype == "blob")) for (i, value) in enumerate(cursor.callproc(name, realargs))) 
    18431849 
    18441850 
     
    18671873        else: 
    18681874            name = "%s.%s" % (self.owner, self.name) 
    1869  
    1870         returnvalue = _promotevalue(cursor.callfunc(name, self._ora2cx[self._returnvalue.datatype], realargs), cursor, self._returnvalue.datatype == "blob") 
     1875        name = cursor._encode(name) 
     1876 
     1877        returnvalue = cursor._decode(cursor.callfunc(name, self._ora2cx[self._returnvalue.datatype], realargs), self._returnvalue.datatype == "blob") 
    18711878        result = Record() 
    18721879        for (i, value) in enumerate(realargs): 
     
    18741881            if arginfo.isout: 
    18751882                value = value.getvalue(0) 
    1876             result[arginfo.name] = _promotevalue(value, cursor, arginfo.datatype == "blob") 
     1883            result[arginfo.name] = cursor._decode(value, arginfo.datatype == "blob") 
    18771884        return (returnvalue, result) 
    18781885 
     
    19141921    def createddl(self, connection=None, term=True): 
    19151922        (connection, cursor) = self.getcursor(connection) 
    1916         cursor.execute("select text from all_source where type='JAVA SOURCE' and owner=nvl(:owner, user) and name=:name order by line", owner=self.owner, name=self.name) 
    1917         code = "\n".join((rec.text or "").rstrip() for rec in cursor) 
     1923        cursor.xexecute("select text from all_source where type='JAVA SOURCE' and owner=nvl(:owner, user) and name=:name order by line", owner=self.owner, name=self.name) 
     1924        code = "\n".join((rec.text or "").rstrip() for rec in cursor.xfetch()) 
    19181925        code = code.strip() 
    19191926 
    1920         code = "create or replace and compile java source named %s as\n%s\n" % (self.getname(), code) 
     1927        code = "create or replace and compile java source named %s as\n%s\n" % (self.getfullname(), code) 
    19211928        if term: 
    19221929            code += "/\n" 
     
    19241931 
    19251932    def dropddl(self, connection=None, term=True): 
    1926         code = "drop java source %s" % self.getname() 
     1933        code = "drop java source %s" % self.getfullname() 
    19271934        if term: 
    19281935            code += ";\n" 
     
    19932000            raise UnknownSchemaError(schema) 
    19942001 
    1995         cursor = connection.cursor() 
     2002        cursor = connection.cursor() # can't use :meth:`getcursor` as we're in a classmethod 
    19962003 
    19972004        if schema == "all": 
    1998             cursor.execute("select decode(table_schema, user, null, table_schema) as owner, privilege, table_name as object, decode(grantor, user, null, grantor) as grantor, grantee from all_tab_privs order by table_schema, table_name, privilege") 
    1999         else: 
    2000             cursor.execute("select null as owner, privilege, table_name as object, decode(grantor, user, null, grantor) as grantor, grantee from user_tab_privs where owner=user order by table_name, privilege") 
    2001         return (Privilege(rec.privilege, rec.object, rec.grantor, rec.grantee, rec.owner, cursor.connection) for rec in cursor) 
     2005            cursor.xexecute("select decode(table_schema, user, null, table_schema) as owner, privilege, table_name as object, decode(grantor, user, null, grantor) as grantor, grantee from all_tab_privs order by table_schema, table_name, privilege") 
     2006        else: 
     2007            cursor.xexecute("select null as owner, privilege, table_name as object, decode(grantor, user, null, grantor) as grantor, grantee from user_tab_privs where owner=user order by table_name, privilege") 
     2008        return (Privilege(rec.privilege, rec.object, rec.grantor, rec.grantee, rec.owner, cursor.connection) for rec in cursor.xfetch()) 
    20022009 
    20032010    def grantddl(self, connection=None, term=True, mapgrantee=True): 
     
    20142021            grantee = self.grantee 
    20152022        elif isinstance(mapgrantee, (list, tuple)): 
    2016             if self.grantee.lower() in map(str.lower, mapgrantee): 
     2023            if self.grantee.lower() in (g.lower() or f in mapgrantee): 
    20172024                grantee = self.grantee 
    20182025            else: 
     
    20482055    def _getcolumnrecord(self, cursor): 
    20492056        name = self.name.split(".") 
    2050         cursor.execute("select * from all_tab_columns where owner=nvl(:owner, user) and table_name=:table_name and column_name=:column_name", owner=self.owner, table_name=name[0], column_name=name[1]) 
    2051         rec = cursor.fetchone() 
     2057        cursor.xexecute("select * from all_tab_columns where owner=nvl(:owner, user) and table_name=:table_name and column_name=:column_name", owner=self.owner, table_name=name[0], column_name=name[1]) 
     2058        rec = cursor.xfetchone() 
    20522059        if rec is None: 
    20532060            raise SQLObjectNotFoundError(self) 
     
    20582065        rec = self._getcolumnrecord(cursor) 
    20592066        name = self.name.split(".") 
    2060         code = ["alter table %s add %s" % (getname(name[0], self.owner), getname(name[1], None))] 
     2067        code = ["alter table %s add %s" % (getfullname(name[0], self.owner), getfullname(name[1], None))] 
    20612068        code.append(" %s" % _columntype(rec)) 
    20622069        default = _columndefault(rec) 
     
    20802087        name = self.name.split(".") 
    20812088 
    2082         code = ["alter table %s modify %s" % (getname(name[0], self.owner), getname(name[1], None))] 
     2089        code = ["alter table %s modify %s" % (getfullname(name[0], self.owner), getfullname(name[1], None))] 
    20832090        # Has the type changed? 
    20842091        if recold.data_precision != recnew.data_precision or recold.data_length != recnew.data_length or recold.data_scale != recnew.data_scale or recold.char_length != recnew.char_length or recold.data_type != recnew.data_type or recold.data_type_owner != recnew.data_type_owner: 
     
    21352142        (connection, cursor) = self.getcursor(connection) 
    21362143        name = self.name.split(".") 
    2137         code = "alter table %s drop column %s" % (getname(name[0], self.owner), getname(name[1], None)) 
     2144        code = "alter table %s drop column %s" % (getfullname(name[0], self.owner), getfullname(name[1], None)) 
    21382145        if term: 
    21392146            code += ";\n" 
     
    21452152        # The column creation date is the table creation date 
    21462153        (connection, cursor) = self.getcursor(connection) 
    2147         cursor.execute("select created from all_objects where lower(object_type)='table' and object_name=:name and owner=nvl(:owner, user)", name=self.name.split(".")[0], owner=self.owner) 
     2154        cursor.xexecute("select created from all_objects where lower(object_type)='table' and object_name=:name and owner=nvl(:owner, user)", name=self.name.split(".")[0], owner=self.owner) 
    21482155        row = cursor.fetchone() 
    21492156        if row is None: 
    21502157            raise SQLObjectNotFoundError(self) 
    2151         return row.created 
     2158        return row[0] 
    21522159 
    21532160    def udate(self, connection=None): 
    21542161        # The column modification date is the table modification date 
    21552162        (connection, cursor) = self.getcursor(connection) 
    2156         cursor.execute("select last_ddl_time from all_objects where lower(object_type)='table' and object_name=:name and owner=nvl(:owner, user)", name=self.name.split(".")[0], owner=self.owner) 
     2163        cursor.xexecute("select last_ddl_time from all_objects where lower(object_type)='table' and object_name=:name and owner=nvl(:owner, user)", name=self.name.split(".")[0], owner=self.owner) 
    21572164        row = cursor.fetchone() 
    21582165        if row is None: 
    21592166            raise SQLObjectNotFoundError(self) 
    2160         return row.last_ddl_time 
     2167        return row[0] 
    21612168 
    21622169    def iterreferences(self, connection=None): 
     
    21992206        name = self.name.split(".") 
    22002207        (connection, cursor) = self.getcursor(connection) 
    2201         cursor.execute("select comments from all_col_comments where owner=nvl(:owner, user) and table_name=:table_name and column_name=:column_name", owner=self.owner, table_name=name[0], column_name=name[1]) 
    2202         rec = cursor.fetchone() 
     2208        cursor.xexecute("select comments from all_col_comments where owner=nvl(:owner, user) and table_name=:table_name and column_name=:column_name", owner=self.owner, table_name=name[0], column_name=name[1]) 
     2209        rec = cursor.xfetchone() 
    22032210        if rec is None: 
    22042211            raise SQLObjectNotFoundError(self) 
  • test/test_orasql.py

    r233 r234  
    2121 
    2222 
    23 # here all objects are collected, so we don't need to call iterobjects() multiple times 
     23# here all objects are collected, so we don't need to call :meth:`iterobjects` multiple times 
    2424objlist = [] 
    2525objdict = {} 
     
    2828def setup_module(module): 
    2929    db = orasql.connect(dbname) 
    30     # get all definitions (this tests that iterdefinition(), iterreferences() and iterreferencedby() run to completion) 
     30    # get all definitions 
     31    # (this tests that :meth:`iterobjects`, :meth:`iterreferences` and :meth:`iterreferencedby` run to completion) 
    3132    module.objdict = {} 
    3233    for obj in db.iterobjects(): 
    33         module.objlist.append(obj) 
    34         references = list(obj.iterreferences()) 
    35         referencedby = list(obj.iterreferencedby()) 
    36         module.objdict[obj] = (references, referencedby) 
     34        if obj.owner is None: 
     35            module.objlist.append(obj) 
     36            references = [o for o in obj.iterreferences() if o.owner is None] 
     37            referencedby = [o for o in obj.iterreferencedby() if o.owner is None] 
     38            module.objdict[obj] = (references, referencedby) 
    3739 
    3840 
     
    7779    for (obj, (references, referencedby)) in objdict.iteritems(): 
    7880        for refobj in references: 
    79             # check that iterobjects() returned everything from this schema 
     81            # check that :meth:`iterobjects` returned everything from this schema 
    8082            assert refobj.owner is not None or refobj in objdict 
    8183            # check that the referenced object points back to this one (via referencedby) 
     
    121123        if isinstance(obj, orasql.Table): 
    122124            for col in obj.itercolumns(): 
    123                 # comments are not output by iterobjects(), so we have to call iterreferences() 
     125                # comments are not output by :meth:`iterobjects`, so we have to call :meth:`iterreferences` 
    124126                assert obj in col.iterreferences() 
    125127                # check various methods 
    126                 # calling modifyddl() doesn't make sense 
     128                # calling :meth:`modifyddl` doesn't make sense 
    127129                col.addddl() 
    128130                col.dropddl() 
     
    138140    for obj in objdict: 
    139141        if isinstance(obj, orasql.Table): 
    140             # comments are output by iterobjects(), but not for materialized views 
     142            # comments are output by :meth:`iterobjects`, but not for materialized views 
    141143            if obj.ismview(): 
    142144                for com in obj.itercomments(): 
     
    189191 
    190192def test_createorder(): 
    191     # check that the default output order of iterobjects() (i.e. create order) works 
     193    # check that the default output order of :meth:`iterobjects` (i.e. create order) works 
    192194    done = set() 
    193195    for obj in objlist: 
     
    276278 
    277279 
    278 def test_fetch(): 
     280def test_xfetch(): 
    279281    for obj in objdict: 
    280282        if isinstance(obj, orasql.Table): 
     
    282284            db = orasql.connect(dbname) 
    283285            c = db.cursor() 
    284             c.execute("select * from %s" % obj.name) 
     286            c.xexecute("select * from %s" % obj.name) 
    285287            c.readlobs = False 
    286             c.fetchone() 
    287             c.execute("select * from %s" % obj.name) 
     288            c.xfetchone() 
     289            c.xexecute("select * from %s" % obj.name) 
    288290            c.readlobs = True 
    289             c.fetchone() 
     291            c.xfetchone() 
    290292            break 
    291293