I am trying to connect an oracle database from my python code using pypyodbc
:
conn_string = "driver={Oracle in OraClient11g_home1}; server='example.oneco.com:1521'; database='tabto'; uid='myuid'; pwd='mypwd'"
conn = pypyodbc.connect(conn_string)
I got error message:
Error: (u'HY000', u'[HY000] [Oracle][ODBC][Ora]ORA-12560: TNS:protocol adapter error\n')
Following is the connection string found in my tnsnames.ora
file. Please tell me what is the right way to use pypyodbc
.
tabto, tabto.world, tabto.oracleoutsourcing.com, tabto.oneco.com =
(DESCRIPTION =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = example.oneco.com)
(PORT = 1521)
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = tabto_dcu)
)
)
The key is link python code to tnsname.ora by defining
dbq
parameter. So change the code to the following worked.