好吧,我希望这不是一个副本,搜索没有产生任何有用的东西。
我一直在玩弄
cx_Oracle
在过去的几天里,安装和使用它。在我遇到当前问题之前,一切都很顺利:我想更改我的模式。如果我使用sqlplus,一个简单的'alter session set current_schema=to to;'就可以了,但是我不知道如何绕过它
cx_甲骨文
.
我下载了最新的源代码版本: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 "<stdin>", line 1, in <module>
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位)
我也编译过
CXI甲骨文
对于64位,在同一台机器上。