Well, I hope this is not a duplicate, the search did not yield anything useful.
I have been toying with cx_Oracle
for the past few days, installing and using it. Everything went fine until I reached my current problem: I'd like to change my schema. If I were using sqlplus a simple 'alter session set current_schema=toto;' would do, but I don't know how to get around it with cx_Oracle
.
I've downloaded the latest source version: cx_Oracle-5.0.2.tar.gz.
According to the documentation changing of schema is a simple case of setting Connection.current_schema
which should be a read-write attribute... the trouble is my Connection
object does not have any current_schema
attribute.
>>> c = cx_Oracle.connect(...)
>>> dir(c)
['__class__', '__delattr__', '__doc__', '__enter__', '__exit__', '__format__',
'__getattribute__', '__hash__', '__init__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__',
'__subclasshook__', 'autocommit', 'begin', 'cancel', 'changepassword', 'close',
'commit', 'cursor', 'dsn', 'encoding', 'inputtypehandler',
'maxBytesPerCharacter', 'nencoding', 'outputtypehandler', 'password', 'prepare',
'register', 'rollback', 'stmtcachesize', 'tnsentry', 'unregister', 'username',
'version']
Trying to set the attribute using
>>> c.current_schema = 'toto'
results in an error... __setattr__
has apparently been overridden to prevent it.
So... does anyone know how to ?
Here is the error I got.
>>> c.current_schema = 'toto'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'cx_Oracle.Connection' object has no attribute 'current_schema'
>>> setattr(c, 'current_schema', 'toto')
# same error
And here are the information about OS and python:
SUSE LINUX Enterprise Server 9 (x86_64)
VERSION = 9
PATCHLEVEL = 3
And I use python 2.6.2 (compiled for 64bits)
I also compiled cx_Oracle
for 64bits, on the very same machine.