microsoft / ODBC-Specification

Microsoft ODBC Specification
Other
121 stars 40 forks source link

No timeouts supported in ODBC Driver XX for SQL Server? #143

Open rayrapetyan opened 4 years ago

rayrapetyan commented 4 years ago

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]

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:

DIAG [01S00] [Microsoft][ODBC Driver 17 for SQL Server]Invalid connection string attribute in trace logs.

So, how to specify timeouts when using "ODBC Driver XX for SQL Server" for Linux?