cx_Oracle.DatabaseError:ORA-12170:TNS:发生连接超时 [英] cx_Oracle.DatabaseError: ORA-12170: TNS:Connect timeout occurred
本文介绍了cx_Oracle.DatabaseError:ORA-12170:TNS:发生连接超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到
cx_Oracle.DatabaseError: ORA-12170: TNS:Connect timeout occurred error while connecting oracle from python.
我已经安装了python 3.7.0和Instantclient_11_2.
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)
我已经设置了系统可验证的 PATH
,其中存在 oci.dll
.
I have set system veriable PATH
where oci.dll
is present.
有什么问题吗?
推荐答案
如果数据库位于同一台计算机上,那么您还应该能够使用以下连接字符串:
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')
请注意,service_name值是必需的.您不能使用空字符串!
Note that a service_name value is required. You can't use the empty string!
这篇关于cx_Oracle.DatabaseError:ORA-12170:TNS:发生连接超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文