You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
thick mode connect isn't honoring TNS_ADMIN or using ldap connection #398
$ python test.py
Traceback (most recent call last):
File "/Users/slords/test.py", line 8, in
c=oracledb.connect(user=user, password=password, dsn=dsn)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/slords/.venv/lib/python3.12/site-packages/oracledb/connection.py", line 1169, in connect
return conn_class(dsn=dsn, pool=pool, params=params, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/slords/.venv/lib/python3.12/site-packages/oracledb/connection.py", line 554, in init
impl.connect(params_impl, pool_impl)
File "src/oracledb/impl/thick/connection.pyx", line 494, in oracledb.thick_impl.ThickConnImpl.connect
File "src/oracledb/impl/thick/utils.pyx", line 446, in oracledb.thick_impl._raise_from_info
oracledb.exceptions.DatabaseError: ORA-12154: Cannot connect to database. Could not find alias whse_dev in /opt/oracle/instantclient_23_3/network/admin/tnsnames.ora.
Help: https://docs.oracle.com/error-help/db/ora-12154/
If I run the same connect using sqlplus it connects fine to the database. I've got sqlnet.ora and ldap.ora in /opt/oracle. We don't use tnsnames.ora and that file has never existed in any of our installs.
Does your application call init_oracle_client()?
Yes
Include a runnable Python script that shows the problem.
unset ORACLE_HOME - this should never be set when using Instant Client
move the sqlnet.ora & ldap.ora files to default location /opt/oracle/instantclient_23_3/network/admin/ and also unset TNS_ADMIN
Enable SQL*Net tracing and check how it is loading the sqlnet.ora / ldap.ora files. I create $HOME/.sqlnet.ora (note the leading period) with something like:
I've unset the variables you suggested, copied the .ora files to the admin directory and enabled tracing but it hasn't helped the situation at all. There is something different between oracledb using the oci layer and sqlplus. They are both reading the sqlnet.ora and ldap.ora files correctly and I can see the attempt to connect to the ldap server. However the oracledb connection is failing.
If possible can you uninstall openldap and run the application? Oracle client libraries come bundled with its own ldap library and there could be some interference with openldap. Could be worth a shot.
Activity
cjbj commentedon Sep 25, 2024
A couple of things to try:
unset ORACLE_HOME - this should never be set when using Instant Client
move the sqlnet.ora & ldap.ora files to default location /opt/oracle/instantclient_23_3/network/admin/ and also unset TNS_ADMIN
Enable SQL*Net tracing and check how it is loading the sqlnet.ora / ldap.ora files. I create
$HOME/.sqlnet.ora(note the leading period) with something like:You can have multiple sqlnet.ora / .sqlnet.ora files: they all get read.
Then check files in
/tmp/oradiag_*/diag/clients/user_cjones/host_*/trace/ora_*.trcCompare with the traces for SQL*Plus.
Try the new LDAP URL syntax which removes the need for sqlnet.ora and ldap.ora, see Oracle Client 23ai
LDAP URL Syntax.
slords commentedon Sep 25, 2024
I've unset the variables you suggested, copied the .ora files to the admin directory and enabled tracing but it hasn't helped the situation at all. There is something different between oracledb using the oci layer and sqlplus. They are both reading the sqlnet.ora and ldap.ora files correctly and I can see the attempt to connect to the ldap server. However the oracledb connection is failing.
This is the part of the trc where they differ.
sqlplus:
oracledb:
I'm not sure what the difference is or why oracledb is getting an 0x2 return and then failing to get the server.
anthony-tuininga commentedon Oct 23, 2024
Can you confirm that both SQL*Plus and python-oracledb are using the same Oracle Client (/opt/oracle/instantclient_23_3)?
slords commentedon Oct 23, 2024
Yes they are. It is the only client installed.
anthony-tuininga commentedon Oct 24, 2024
Some more questions from the network experts at Oracle:
slords commentedon Oct 24, 2024
Yes I have openldap installed. Setting DYLD_PRINT_LIBRARIES=YES does not show it trying to load openldap.
sreguna commentedon Oct 24, 2024
If possible can you uninstall openldap and run the application? Oracle client libraries come bundled with its own ldap library and there could be some interference with openldap. Could be worth a shot.
slords commentedon Oct 24, 2024
There are not changes between having openldap installed and not.
anthony-tuininga commentedon Jan 29, 2026
@slords, is this still an issue for you?
slords commentedon Jan 30, 2026
Yes
cjbj commentedon Apr 30, 2026
I wonder if this still reproduces with the newer 23.26.1.0.0 client for macOS ARM (https://www.oracle.com/database/technologies/instant-client/macos-arm64-downloads.html)
anthony-tuininga commentedon Apr 30, 2026
@slords, can you check?