I've been unable to find a documented way to set a timeout for the initial connection that actually works. I'm not asking about a "query timeout", but rather a timeout on an initial connection attempt in the case that the DB server is completely down or unreachable, and there's no response at all. By default, such connections appear to timeout after 255 seconds - is there a way to set a shorter timeout?
Edit: for clarity, I should reiterate the stack here:
- python
- pyodbc
- unixODBC (not iODBC)
- MS ODBC Driver 11 for SQL Server (not FreeTDS)
- Linux
connect timeout = X
in yourodbc.ini
file - it shouldn't work but it might be an undocumented workaround. If so, I wouldn't trust it in a production environment. – Commotion