来自python的Oracle DB的连接超时参数 [英] Connection timeout parameter for Oracle DB from python

查看:544
本文介绍了来自python的Oracle DB的连接超时参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用下面的简单代码连接到Oracle数据库以执行存储过程.但是在连接到数据库或使用callproc函数执行存储过程时,在任何地方都看不到任何超时参数.

I am using the below simple code to connect to Oracle database to execute a stored procedure. But am not seeing any timeout parameter anywhere while connecting to DB or executing the stored procedure using the callproc function.

有人可以建议如何在python中为Oracle实现超时"!

Can someone please suggest how to implement "timeout" in python for Oracle!

self.db_connection = cx_Oracle.connect(self.connection_str)
try:
    if self.cursor is None:
        self.cursor = self.db_connection.cursor()
 except:
    raise

推荐答案

通常,有两种方法可以在一段时间后停止DB执行.

In general there are two ways to stop DB execution after a period of time.

  • 数据库具有资源管理器,该资源管理器可用于限制数据库资源,如果超出数据库资源则返回错误.

  • The Database has a resource manager than can be used to limit DB resources and return an error if they are exceeded.

您可以通过创建 Oracle Net Services文档.

you can configure the Oracle Net layer used by cx_Oracle by creating a sqlnet.ora configuration file with various timeout parameters such as SQLNET.INBOUND_CONNECT_TIMEOUT, SQLNET.RECV_TIMEOUT and SQLNET.SEND_TIMEOUT etc. Check the Oracle Net Services documention.

对于连接,请使用后者

这篇关于来自python的Oracle DB的连接超时参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆