好吧,我希望这不是重复,搜索没有产生任何有用的东西.
在过去的几天里,我一直在玩cx_Oracle,安装和使用它.在我遇到当前问题之前,一切都很顺利:我想改变我的架构.如果我使用sqlplus一个简单的’alter session set current_schema = toto;’会怎么做,但我不知道怎么用cx_Oracle解决它.
我已经下载了最新的源代码:cx_Oracle-5.0.2.tar.gz.
根据documentation更改架构是一个简单的设置Connection.current_schema的情况,它应该是一个读写属性…麻烦的是我的Connection对象没有任何current_schema属性.
>>> 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']
尝试使用设置属性
>>> c.current_schema = 'toto'
导致错误… __setattr__显然已被覆盖以防止它.
那么……有谁知道怎么做?
这是我得到的错误.
>>> c.current_schema = 'toto'
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'cx_Oracle.Connection' object has no attribute 'current_schema'
>>> setattr(c, 'current_schema', 'toto')
# same error
以下是有关OS和python的信息:
SUSE LINUX Enterprise Server 9 (x86_64)
VERSION = 9
PATCHLEVEL = 3
我使用python 2.6.2(编译为64位)
我也在同一台机器上编译了64位的cx_Oracle.