Reputation: 21
I am getting
cx_Oracle.DatabaseError: ORA-12170: TNS:Connect timeout occurred error while connecting oracle from python.
I have installed python 3.7.0 and instantclient_11_2.
Below are the process i am doing,
import cx_Oracle
dsn_tns = cx_Oracle.makedsn( '<ip>', 1521, service_name = '<given service name>')
connection = cx_Oracle.connect('user', 'pwd', dsn_tns)
I have set system veriable PATH
where oci.dll
is present.
What could be wrong?
Upvotes: 2
Views: 9945
Reputation: 7096
You should also be able to use the following connect string if the database resides on the same machine:
connection = cx_Oracle.connect('user/pwd@localhost/service_name')
Note that a service_name value is required. You can't use the empty string!
Upvotes: 1
Reputation: 2015
Try:
connection = cx_Oracle.connect('user', 'pwd', cx_Oracle.makedsn( '<ip>', '1521',None,'<given service name>'))
Looks the same but works different in my ubuntu server.
Also make sure to put the port between ' '
Upvotes: 0