混淆破译错误代码 Python 模块连接到 Oracle (cx_Oracle)
Confusion Deciphering Error Code Python Module To Connect To Oracle (cx_Oracle)
你们都被解雇了。除此之外,我需要帮助破译我在尝试使用 cx_Oracle 模块连接到 Oracle 数据库时看到的错误代码。出于一些不负责任和愚蠢的原因,我使用 Python2.7 而不是 Python3000。我看到的错误信息如下(当然是copy/pasted):
>>> 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数据库吗?
下面的 copy/paste 显示了来自其中一个数据库的横幅。
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.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
我想通了。我按照上面的错误信息中的link然后下载了32位的即时客户端精简版软件并将其作为第一件事在我的道路上。然后我按照手册将 tnsnames.ora 文件放在我从 TNS_NAMES 环境变量引用的第二个路径上。 :) 希望这有助于以后的一些抱歉混蛋。 :D
一个更简单的选项 是重新安装 Python 的实现。就我而言,我需要 64 位 Python 才能与 64 位 Oracle DBMS 软件进行通信。
对于造成的混乱,我们深表歉意。错误消息中存在错误。这只发生在非常旧版本的 Oracle 客户端库中。我刚刚在此处更正了此内容:https://github.com/oracle/odpi/commit/d2fea3801286d054e18b0102e60a69907b7faa9a 并将很快作为 cx_Oracle 7.1.1 的一部分发布。
所以错误消息真正想告诉您的是,您需要 11.2 或更高版本的 Oracle Client 库,并且您的版本太旧以至于它甚至不知道如何告诉您它是什么版本!所以很可能是 8i 或 9i 或 10g 的早期版本。对于那些旧版本,它们经常存储在 c:\Windows\system32 中,因此优先于您可能已安装的其他库。您可以通过将 PATH 环境变量设置为在 beginning 处包含 C:\app\client\corporateDrone\product.1.0\client_1\bin 来强制解决此问题。如果这没有帮助,您可能必须找到并删除旧版本的 OCI.dll —— 请记住,这样做会影响依赖它的任何软件!
官方文档可以在这里找到:https://cx-oracle.readthedocs.io/en/latest/index.html. There is an enhancement request to include these in the builtin help that you noted doesn't have anything useful. :-) You can see the enhancement request here: https://github.com/oracle/python-cx_Oracle/issues/175.
希望这能减轻您的困惑!
你们都被解雇了。除此之外,我需要帮助破译我在尝试使用 cx_Oracle 模块连接到 Oracle 数据库时看到的错误代码。出于一些不负责任和愚蠢的原因,我使用 Python2.7 而不是 Python3000。我看到的错误信息如下(当然是copy/pasted):
>>> 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数据库吗?
下面的 copy/paste 显示了来自其中一个数据库的横幅。
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.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
我想通了。我按照上面的错误信息中的link然后下载了32位的即时客户端精简版软件并将其作为第一件事在我的道路上。然后我按照手册将 tnsnames.ora 文件放在我从 TNS_NAMES 环境变量引用的第二个路径上。 :) 希望这有助于以后的一些抱歉混蛋。 :D
一个更简单的选项 是重新安装 Python 的实现。就我而言,我需要 64 位 Python 才能与 64 位 Oracle DBMS 软件进行通信。
对于造成的混乱,我们深表歉意。错误消息中存在错误。这只发生在非常旧版本的 Oracle 客户端库中。我刚刚在此处更正了此内容:https://github.com/oracle/odpi/commit/d2fea3801286d054e18b0102e60a69907b7faa9a 并将很快作为 cx_Oracle 7.1.1 的一部分发布。
所以错误消息真正想告诉您的是,您需要 11.2 或更高版本的 Oracle Client 库,并且您的版本太旧以至于它甚至不知道如何告诉您它是什么版本!所以很可能是 8i 或 9i 或 10g 的早期版本。对于那些旧版本,它们经常存储在 c:\Windows\system32 中,因此优先于您可能已安装的其他库。您可以通过将 PATH 环境变量设置为在 beginning 处包含 C:\app\client\corporateDrone\product.1.0\client_1\bin 来强制解决此问题。如果这没有帮助,您可能必须找到并删除旧版本的 OCI.dll —— 请记住,这样做会影响依赖它的任何软件!
官方文档可以在这里找到:https://cx-oracle.readthedocs.io/en/latest/index.html. There is an enhancement request to include these in the builtin help that you noted doesn't have anything useful. :-) You can see the enhancement request here: https://github.com/oracle/python-cx_Oracle/issues/175.
希望这能减轻您的困惑!