oracle / python-oracledb

Python driver for Oracle Database conforming to the Python DB API 2.0 specification. This is the renamed, new major release of cx_Oracle
https://oracle.github.io/python-oracledb
Other
328 stars 66 forks source link

oracledb thin mode: DPY-4000 (Unable to find <DBNAME> in tnsnames.ora #115

Closed avmcohen closed 1 year ago

avmcohen commented 1 year ago

Hi While connecting to DB in thin mode, getting the title ERROR (DPY-4000). The scenario is only when providing the TNS alias in to dsn argument. (ERROR: oracledb.exceptions.DatabaseError: DPY-4000: cannot connect to database. Unable to find "<????>" in /tnsadmin/tnsnames.ora)

When providing full TNS address (IP address:port/DSN) - it connecting fine. This happened only in thin mode. In thick mode (and cx_Oracle) it work fine.

anthony-tuininga commented 1 year ago

Can you provide the syntax you are using? It looks like you are providing an empty string?

avmcohen commented 1 year ago

import oracledb as ora dbs = ora.connect(user = 'UserName', password = 'Pasword', dsn = 'TNS alias')

While using: import cx_Oracle as ora connection works.

anthony-tuininga commented 1 year ago

Interesting! Are you able to share your tnsnames.ora file? You can e-mail it directly to me if you prefer not to share it here.

avmcohen commented 1 year ago

Sorry !! You are right.. followed your note I checked the TNS file, and it was corrupted.. few lines before the DB I connected, the Parenthesis was not closed.. Still it's interesting why sqlplus and cx_Oracle easily skipped on corrupted line and found my DB alias. Thanks a lot !