Skip to content

Commit ba68198

Browse files
committed
add query_timeout option
1 parent 6acbf5d commit ba68198

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ Dictionary. Current available keys are:
203203
Integer. Sets the back off time in seconds for reries of
204204
the database connection process. Default value is ``5``.
205205

206+
- query_timeout
207+
208+
Integer. Sets the timeout in seconds for the database query.
209+
Default value is ``0`` which disables the timeout.
210+
206211
backend-specific settings
207212
~~~~~~~~~~~~~~~~~~~~~~~~~
208213

sql_server/pyodbc/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ def get_new_connection(self, conn_params):
301301
timeout = options.get('connection_timeout', 0)
302302
retries = options.get('connection_retries', 5)
303303
backoff_time = options.get('connection_retry_backoff_time', 5)
304+
query_timeout = options.get('query_timeout', 0)
304305

305306
conn = None
306307
retry_count = 0
@@ -323,6 +324,7 @@ def get_new_connection(self, conn_params):
323324
if not need_to_retry:
324325
raise
325326

327+
conn.timeout = query_timeout
326328
return conn
327329

328330
def init_connection_state(self):

0 commit comments

Comments
 (0)