Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

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

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

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

From what I gather this plug-in is only for 11g Oracle databases and maybe lower. The pluggable database(s) I am using and the normal databases, lack of a better term, are all 12c. Is this plug-in only for version <=11 of the Oracle database?

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

Respectfully,

A dumb guy

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

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:appclientcorpDroneproduct12.1.0client_1inoci.dll is not the correct a
rchitecture". See https://oracle.github.io/odpi/doc/installation.html#windows fo
r help

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
120 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.

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:Windowssystem32 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:appclientcorporateDroneproduct12.1.0client_1in 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!

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.

Hopefully that alleviates your confusion!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...