I am trying to connect to a database using cx_Oracle in Python. this is the way I'm doing it :
connection = cx_Oracle.connect("user", "pass", "service")
I am able to connect to the db using sql developer with the same credentials but when I try to connect from python it throws the error :
ORA-12154: TNS:could not resolve the connect identifier specified.
I tried the same thing from another system and I am able to connect to the database using cx_Oracle
. The contents of TNSNames.ora file are exactly the same in both systems.
I removed everything and installed again hoping to get rid of mistakes I might have done the first time but I am still facing the same error.
Please let me know if there is any way to fix this.
Thank You.
I realised what was going wrong. The database uses a LDAP file. And in the SQLNET.ORA file, LDAP was not mentioned, that caused the error for me. Just adding LDAP to NAMES.DIRECTORY_PATH in SQLNET.ORA solved this issue for me.