Reputation: 35
I am trying to connect my Oracle XE database (a single instance) using the Python code. First the parameters were without config_dir
, then I added it hoping Python searched for tnsnames.ora
.
import getpass
import oracledb
# ===== config_fir is location tnsnames.org
c = oracledb.connect(user='sys', password="my_password", dsn="xe", config_dir="E:/oracle_21c/homes/OraDB21Home/network/admin")
print("Successfully connected to Oracle Database")
Error:
file tnsnames.ora not found in E:/oracle_21c/homes/OraDB21Home/network/admin
Upvotes: 0
Views: 82
Reputation: 11586
If you just do "dsn=abc" then we are going to look for a file called tnsnames.ora which contains the entry "abc", because that will then identify the host, port and service you want to connect to.
It might be easier initially just to go direct, eg
c= oracledb.connect(user="...", password="...",
host="yourhost", port=1521, service_name="yourdb")
Upvotes: 0