1

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.

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
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Abhijit
  • 21
  • 2
  • 1
    Possible duplicate of [Set database connection timeout in Python](https://stackoverflow.com/questions/2374079/set-database-connection-timeout-in-python) – mikuszefski Dec 14 '17 at 14:23

1 Answers1

0

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.

  • 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.

For connections, use the latter

Christopher Jones
  • 9,449
  • 3
  • 24
  • 48