混淆解密错误代码Python模块以连接到Oracle(cx_Oracle) [英] Confusion Deciphering Error Code Python Module To Connect To Oracle (cx_Oracle)

查看:117
本文介绍了混淆解密错误代码Python模块以连接到Oracle(cx_Oracle)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你们都被解雇了.除了这件事,我还需要其他一些帮助来解密在尝试使用 cx_Oracle 模块连接到Oracle数据库时看到的错误代码.由于某些不负责任的原因,我使用的是Python2.7而不是Python3000.我看到的错误消息如下(当然是复制/粘贴):

You all are fired. That matter aside, I need help deciphering an error code I am seeing when trying to use the cx_Oracle module to connect to an Oracle database. For some irresponsible and moronic reason I am using Python2.7 instead of Python3000. The error message I see is as follows (copy/pasted of course):

>>> 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')

I found some terrible documentation inside the module itself via this command: help('cx_Oracle.connect')

此命令产生以下页面,为简洁起见,仅显示第一页面:

This command yields the following page, first page only shown for conciseness:

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​​的更好解释:

I found a better explanation on how to use the API at the following web page: https://dzone.com/articles/python-code-can-connect-oracle

一个人想知道为什么模块作者没有像网页的作者那样写清楚的指令,例如:

One wonders why the module authors did not write clear instructions as the author of the web page did such as:

# 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

I also found some more documentation at the following URL: https://developer.oracle.com/databases/database-for-python-developers-1

该文档可能来自另一个时代,用于Oracle数据库的较早实现.

This documentation maybe from another era and for an earlier implementation of the Oracle database.

从我收集的信息来看,此插件仅适用于11g Oracle数据库,甚至可能更低.我正在使用的可插拔数据库和缺少更好术语的普通数据库均为12c.此插件仅适用于< = 11版本的Oracle数据库吗?

下面的复制/粘贴显示来自其中一个数据库的横幅.

The copy/paste below shows a banner from one of the databases.

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

尊敬的

一个愚蠢的人

---------------------- UPDATE ------------------------ ----------------------------

----------------------UPDATE----------------------------------------------------

我接受了对该软件项目的建议很有帮助的开发人员,现在收到一个新错误.我删除了关于Oracle DB版本11的一些我认为不需要的东西,并看到了一条新的错误消息:

I took the helpful dev on this software project's advice and now I receive a new error. I deleted some things I do not think I need from my path regarding version 11 of the Oracle DB and see a new error message:

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

I figured it out. I followed the link in the error message above and then downloaded the 32 bit instant client lite software and put this as the first thing in my path. Then I followed the manual and put the tnsnames.ora file on my path second referenced from the TNS_NAMES environment variable. :) Hope this helps some sorry jerk later. :D

一个更简单的选项是重新安装Python的实现.就我而言,我需要64位Python与64位Oracle DBMS软件进行通信.

An even simpler option is to re-install your implementation of Python. In my case I need 64bit Python to communicate with the 64bit Oracle DBMS software.

推荐答案

抱歉造成的歉意.错误消息中有一个错误.这仅在非常旧的Oracle Client库版本中发生.我刚刚在这里更正了这个问题: https://github.com/oracle/odpi/commit/d2fea3801286d054e18b0102e60a69907b7faa9a ,并将很快作为cx_Oracle 7.1.1的一部分发布.

Apologies for the confusion. There was a bug in the error message. This only occurs with very old versions of the Oracle Client libraries. I've just corrected this here: https://github.com/oracle/odpi/commit/d2fea3801286d054e18b0102e60a69907b7faa9a and that will be released as part of cx_Oracle 7.1.1 soon.

因此错误消息真正要告诉您的是,您需要具有11.2或更高版本的Oracle Client库,并且版本足够老,甚至不知道如何告诉您它是哪个版本!因此可能是8i或9i或10g的早期版本.对于那些较旧的版本,它们通常存储在c:\ Windows \ system32中,因此优先于您可能已安装的其他库.您可以通过将PATH环境变量设置为在开始处包含C:\ app \ client \ corporateDrone \ product \ 12.1.0 \ client_1 \ bin来强制执行此问题.如果这样做没有帮助,则可能必须找到并删除较旧的OCI.dll版本-请记住,这样做会影响依赖于此的任何软件!

So what the error message is really trying to tell you is that you need to have 11.2 or higher Oracle Client libraries and you have a version old enough that it doesn't even know how to tell you what version it is! So likely 8i or 9i or early versions of 10g. With those older versions they were frequently stored in c:\Windows\system32 and thus take precedence over other libraries that you may have installed. You can force the issue by setting your PATH environment variable to include the C:\app\client\corporateDrone\product\12.1.0\client_1\bin at the beginning. If that doesn't help, you may have to find and remove the older version of OCI.dll -- keeping in mind that doing so will affect any software that depends on it!

可以在此处找到官方文档: https://cx-oracle .readthedocs.io/en/latest/index.html .有一个增强请求,要求您将其包含在内置帮助中,而您注意到这些帮助没有任何用处. :-)您可以在此处看到增强请求: https://github.com/oracle /python-cx_Oracle/issues/175 .

The official documentation can be found here: 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.

希望能减轻您的困惑!

这篇关于混淆解密错误代码Python模块以连接到Oracle(cx_Oracle)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆