Skip to content
Advertisement

Cx Oracle ‘TNS could not resolve the connect identifier’

I am connecting to an Oracle DB using LDAP and the Python cx_Oracle library. I have proper sqlnet.ora, ldap.ora and tnsnames.ora files. On my Windows machine everything works fine using the 12.1 Oracle client and the following Python code:

import cx_Oracle
connection = cx_Oracle.connect(user/password@db, mode=cx_Oracle.SYSDBA)

I have installed the Oracle instant client 12.1 on my Linux machine (Debian) following the zip file installation method advised on the Oracle website (at the bottom of https://www.oracle.com/be/database/technologies/instant-client/linux-x86-64-downloads.html). ldconfig correctly lists the oracle client libraries and their paths.

I copy the exact same sqlnet.ora, ldap.ora and tnsnames.ora files from my Windows machine to my Linux machine in /opt/oracle/instantclient_12_1/network/admin, as advised by the cx_Oracle documentation.

Now running the above Python code on my Linux machine I have the following error:

cx_Oracle.DatabaseError: ORA-12154: TNS:could not resolve the connect identifier specified

I tried as well setting the environment variable TNS_ADMIN=/opt/oracle/instantclient_12_1/network/admin and ORACLE_HOME=/opt/oracle/instantclient_12_1/ with no success neither

Could any of you help me debugging this and understand why the client config on my Linux machine does not work?

Advertisement

Answer

Installed the latest 19 client and everything works as expected.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement