Looks like "ODBC Driver XX for SQL Server" for Linux (I've checked versions 13 and 17) doesn't support any timeout options. I've tried all possible combinations, e.g.:
"LoginTimeout"
"Login Timeout"
"Login_Timeout"
"ConnectTimeout"
"Connect Timeout"
"Connect_Timeout"
a
nd none of them are recognized by the driver.
Here is my test code:
import pyodbc as odbc
conn = odbc.connect('Driver={ODBC Driver 17 for SQL Server};Server=mymssqlserver;Database=mydatabse;LoginTimeout=3;')
I've disabled local network and it always takes ~15 seconds before it returns:
SQLState = [HYT00]
Native = 0x7ffe15aab9f0 -> 0
Message Text = [[Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired]
Looks like "ODBC Driver XX for SQL Server" for Linux (I've checked versions 13 and 17) doesn't support any timeout options. I've tried all possible combinations, e.g.:
Here is my test code:
I've disabled local network and it always takes ~15 seconds before it returns:
As per docs: https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/odbc-driver-on-linux-support-for-high-availability-disaster-recovery loginTimeout options should be supported, but there is no such string in a driver binary, and when specified you'll get:
So, how to specify timeouts when using "ODBC Driver XX for SQL Server" for Linux?