How to fix timeout error in connection using pyodbc in airflow
Xavier Langa
0
Reputation points
Hi,
I am running an airflow DAG in docker, where I connect to sql server 2019 using a pyodbc connection function.
My connection function is as:
def get_db_connection():
return pyodbc.connect(
'DRIVER={ODBC Driver 17 for SQL Server};'
'SERVER=xxx.xxx.x.xx\\XXX2024;'
'DATABASE=somedatabase;'
'UID=username;'
'PWD=password;'
)
When the connection exceeds 15 seconds, I get this error:
return pyodbc.connect( pyodbc.OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')
even when setting:
connection.timeout = 30
Can someone help me?
Sign in to answer