你们都被解雇了。撇开这件事不谈,我需要帮助来破译我在尝试使用cx_Oracle模块连接到 Oracle 数据库时看到的错误代码。由于一些不负责任和愚蠢的原因,我使用 Python2.7 而不是 Python3000。我看到的错误信息如下(当然是复制/粘贴):
>>> connection = cx_Oracle.connect('user', 'password123', 'db1')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cx_Oracle.DatabaseError: DPI-1050: Oracle Client library is at version 11.2 but
must be at version 0.0 or higher
>>>
我通过以下命令在模块本身内发现了一些糟糕的文档:help('cx_Oracle.connect')
此命令产生以下页面,第一页仅为简洁起见:
Help on class Connection in cx_Oracle:
cx_Oracle.connect = class Connection(__builtin__.object)
| Methods defined here:
|
| __enter__(...)
|
| __exit__(...)
|
| __init__(...)
| x.__init__(...) initializes x; see help(type(x)) for signature
|
| __repr__(...)
| x.__repr__() <==> repr(x)
|
| begin(...)
|
| cancel(...)
|
| changepassword(...)
|
| close(...)
|
| commit(...)
|
| createlob(...)
|
| cursor(...)
|
| deq(...)
|
| deqoptions(...)
|
| enq(...)
|
| enqoptions(...)
|
| getSodaDatabase(...)
|
| gettype(...)
|
| msgproperties(...)
|
| ping(...)
|
| prepare(...)
-- More --
我在以下网页上找到了有关如何使用 API 的更好解释:https ://dzone.com/articles/python-code-can-connect-oracle
有人想知道为什么模块作者没有像网页作者那样写出清晰的说明,例如:
# Connect using the ordered parameters user, password and SID.
dbconn = cx_Oracle.connect('user', 'password' ,'SID')
我还在以下 URL 找到了更多文档:https ://developer.oracle.com/databases/database-for-python-developers-1
该文档可能来自另一个时代,用于 Oracle 数据库的早期实现。
据我所知,这个插件仅适用于 11g 的 Oracle 数据库,可能更低。我使用的可插拔数据库和普通数据库,没有更好的术语,都是 12c。此插件是否仅适用于版本 <=11 的 Oracle 数据库?
下面的复制/粘贴显示了来自其中一个数据库的横幅。
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing op
ions
尊敬,
一个笨蛋
- - - - - - - - - - - 更新 - - - - - - - - - - - - - - -------------------------
我接受了这个软件项目建议的有用开发人员,现在我收到一个新错误。我从关于 Oracle DB 版本 11 的路径中删除了一些我认为不需要的东西,并看到一条新的错误消息:
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (
Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>> connection = cx_Oracle.connect('user', 'password', 'oracledb')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cx_Oracle.DatabaseError: DPI-1047: 32-bit Oracle Client library cannot be loaded
: "C:\app\client\corpDrone\product\12.1.0\client_1\bin\oci.dll is not the correct a
rchitecture". See https://oracle.github.io/odpi/doc/installation.html#windows fo
r help
我想到了。我按照上面错误消息中的链接,然后下载了 32 位即时客户端精简版软件,并将其作为我路径中的第一件事。然后我按照手册将 tnsnames.ora 文件放在从 TNS_NAMES 环境变量引用的第二个路径上。:) 希望这对以后有些抱歉的混蛋有所帮助。:D
一个更简单的选择是重新安装 Python 的实现。就我而言,我需要 64 位 Python 才能与 64 位 Oracle DBMS 软件进行通信。