python - cx_Oracle 连接超时

标签 python python-3.x oracle

我正在尝试连接到 Oracle 数据库,但出现以下错误:

curcon = cx_Oracle.connect(conn_str) cx_Oracle.DatabaseError: ORA-12170: TNS:Connect timeout occurred

这是代码块:

conn_str = u'user/pwd@111.22.33.444:8000/service'
curcon = cx_Oracle.connect(conn_str) 
cursor = curcon.cursor()

我尝试了这两个线程的解决方案,但没有一个有效:

Set database connection timeout in Python

ORA-12170: TNS:Connect timeout occurred

最佳答案

如果由于网络或系统速度慢而发生错误,您可以通过将 sqlnet.ora 中的以下参数重新配置为更大的值来修复错误:

SQLNET.INBOUND_CONNECT_TIMEOUT = 0

您的 sqlnet.ora 文件可以在 $ORACLE_HOME/network/admin 目录中找到。

关于python - cx_Oracle 连接超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58241993/

相关文章:

c - Oracle Pro*C : Handling end of fetch cursor

oracle - 使用 PL\SQL Developer 7.0.2 调试 Oracle 触发器?

python - Numpy 比纯 C 更快?

python - 使用openCV确定文本中的分割线

python - Python 何时检查 ABC 的具体子类是否实现了所需的方法?

python-3.x - 基于 if-then 语句的两个玩家 python Tic-Tac-Toe 程序

php - oci_execute() : OCI_SUCCESS_WITH_INFO: ORA-24344 using a trigger/sequence to auto increment an oracle table error

python - 如何使用 csv 数据作为变量将其应用于公式?

python - 将行写入新的数据帧

python - 如何绘制单个 3D 点?