-
Is it possible to achieve the same behivor as a local passwordless OS authentification ? Here is an example of a local os connection with username "oracle".
I would like to achieve the same thing with python, with running the python script as oracle user context, on the local server, without the need to provide a password when doing "oracledb.connect". But it looks like the API can only achieve this with a net tns alias. Here is what I tried with a net alias, but it is not working.
import oracledb
oracledb.init_oracle_client(lib_dir="/u01/app/19.0.0/oracle/db_1/lib", config_dir="/u01/app/19.0.0/oracle/db_1/network/admin")
connection = oracledb.connect(dsn="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orsni401)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=LABOAAD)))")
cursor = connection.cursor()
cursor.execute("select sysdate from dual")
print(cursor.fetchall())
Here are my OS settings :
Also, this is not working :
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
In your call to
But, having said that, sort out your issue with SQL*Plus first. Are you using a PDB? (And I formally have to advise against setting |
Beta Was this translation helpful? Give feedback.
-
I made a successful local OS authentification with env variables like this : import oracledb
import os
oracledb.init_oracle_client()
os.environ['ORACLE_SID'] = 'LABOAAD1'
print(os.environ.get('ORACLE_SID'))
connection = oracledb.connect()
cursor = connection.cursor()
cursor.execute("SELECT SYS_CONTEXT ('USERENV', 'SESSION_USER') FROM DUAL")
print(cursor.fetchall())
os.environ['ORACLE_SID'] = 'LABOBBD1'
print(os.environ.get('ORACLE_SID'))
connection2 = oracledb.connect()
cursor = connection2.cursor()
cursor.execute("SELECT SYS_CONTEXT ('USERENV', 'SESSION_USER') FROM DUAL")
print(cursor.fetchall()) |
Beta Was this translation helpful? Give feedback.
I made a successful local OS authentification with env variables like this :