pypyodbc "Login timeout expired" error on linux, same code working on windows machine

Viewed 33

I have the below pypyodbc code running on my windows computer connecting to a windows server with a SQL database. When I use the exact same code on a linux machine in the same network I receive a

pypyodbc.OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired')

error. The suggestions in this Stackoverflow question or this question did not help. The query on the windows machine is successful, I can ping the windows server from both machines. Both machines run the pypyodbc version 1.3.5

import pypyodbc as pyodbc

server = "XXX.XXX.X.XX\INSTANCENAME"

port = "1433"

database = "DATABASENAME"

user = "sa"

PWD = "XXX"

tcon = "no"

driver = '{ODBC Driver 17 for SQL Server}'

con = pyodbc.connect(Trusted_Connection=tcon, driver = driver, server = server , database = database, UID=user, PWD=PWD)

crsr = con.cursor()

crsr.execute("SELECT * FROM dbo.DigiCenter where Number = '"+str(123456) +"'")
    
for row in crsr.fetchall():
    print(row)
    
con.close()
0 Answers
Related