Amir
Amir

Reputation: 27

DB Connect failure python cx_Oracle - ORA-01804

I try to connect oracle DB with cx_Oracle package in python 3.9.7. cx_Oracle version is 8.3.0.

when i try to connect with command cx_Oracle.clientversion() i got error :

DatabaseError: Error while trying to retrieve text for error ORA-01804

Linux Os , attach my .bash_profile

with sqlplus command i success to connect the DB.

.bash_profile :

enter image description here

Thanks

Upvotes: 0

Views: 3998

Answers (2)

Mike
Mike

Reputation: 1

With a full Oracle client under Windows we did run into this error “DatabaseError: Error while trying to retrieve text for error ORA-01804” as well and it took us quite a while to solve it. With on the laptop the Oracle client in the Path-variable pointing to the bin-folder and with TNS_ADMIN already set the only needed environment variable to be set via the Pythons script was this one:

os.putenv('LD_LIBRARY_PATH', 'C:\Ora19c64\product\19.3.0\client_64\bin')

It is not intuitive to point for LD_LIBRARY_PATH to the bin-folder instead of the lib-folder, but it solved the issue.

Upvotes: 0

Anthony Tuininga
Anthony Tuininga

Reputation: 7096

This error generally occurs when there is a discrepancy between the value of the environment variable ORACLE_HOME and the actual library that was loaded. You can set the environment variable DPI_DEBUG_LEVEL to the value 64 and run your script. It will tell you which method was used to load the library. If that doesn't help you figure it out, paste the output in your question and I'll try to help further.

Note as well that there is a new driver available (python-oracledb) which doesn't require Oracle Client libraries and therefore shouldn't run into this issue. Take a look here: https://levelup.gitconnected.com/open-source-python-thin-driver-for-oracle-database-e82aac7ecf5a

Upvotes: 0

Related Questions