I am trying to use Oracle's python-oracledb library to connect to an Oracle db that I've been able to connect to just fine manually in Oracle SQL Developer. I'm developing in VSCode using WSL Ubuntu on a VPN-connected VM owned by my company
Using a simple dict of info/credentials for a specific database, e.g.
db_info = {
'rdbms': 'Oracle',
'dsn': oracledb.makedsn(oracle_am_db_host, oracle_am_db_port, sid=oracle_am_db_sid),
'user': oracle_user,
'pass': oracle_pass
}
I try to connect as in Oracle's docs with username, password, and DSN (also having tried using DSN format f'{db_name}:{db_port}/{db_sid}' instead of oracledb's makedsn function)
conn = oracledb.connect(user=db_info['user'], password=db_info['pass'], dsn=db_info['dsn'])
but get the stack trace & error message:
Traceback (most recent call last):
File "/home/user1/get-schemas-counts/get-schemas-counts.py", line 114, in <module>
table_data = get_tables_counts(build_db_conn(db_info))
File "/home/user1/get-schemas-counts/get-schemas-counts.py", line 51, in build_db_conn
conn = oracledb.connect(user=db_info['user'], password=db_info['pass'], dsn=dsn_attempt)
File "/home/user1/.local/lib/python3.10/site-packages/oracledb/connection.py", line 1134, in connect
return conn_class(dsn=dsn, pool=pool, params=params, **kwargs)
File "/home/user1/.local/lib/python3.10/site-packages/oracledb/connection.py", line 523, in __init__
impl.connect(params_impl)
File "src/oracledb/impl/thin/connection.pyx", line 449, in oracledb.thin_impl.ThinConnImpl.connect
File "src/oracledb/impl/thin/connection.pyx", line 445, in oracledb.thin_impl.ThinConnImpl.connect
File "src/oracledb/impl/thin/connection.pyx", line 411, in oracledb.thin_impl.ThinConnImpl._connect_with_params
File "src/oracledb/impl/thin/connection.pyx", line 392, in oracledb.thin_impl.ThinConnImpl._connect_with_description
File "src/oracledb/impl/thin/connection.pyx", line 358, in oracledb.thin_impl.ThinConnImpl._connect_with_address
File "/home/user1/.local/lib/python3.10/site-packages/oracledb/errors.py", line 162, in _raise_err
raise exc_type(_Error(message)) from cause
oracledb.exceptions.OperationalError: DPY-6005: cannot connect to database (CONNECTION_ID=sR7jFJ3PnW2DK76pG1OGAw==).
[Errno -2] Name or service not known
Thinking this might be a DNS issue from some threads I've read, I tried adding some more expansive nameservers to my /etc/resolv.conf file but to no avail. Also tried restarting my terminal sessions