0

I have run my code within Spyder and I get no error. When I run the same python3 code in my Ubuntu VM I receive the following error:

Traceback (most recent call last): File "Script - Full.py", line 40, in conn = pyodbc.connect('DRIVER='+driver+';SERVER='+server+';DATABASE='+database+';Trusted_Connection='+trusted) pyodbc.OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')

My current code that the error is referring to is:

server = 'SERVER_NAME'
database = 'DATABASE_NAME'
trusted = 'yes'
driver= '{ODBC Driver 17 for SQL Server}'
conn = pyodbc.connect('DRIVER='+driver+';SERVER='+server+';DATABASE='+database+';Trusted_Connection='+trusted)

Where I'm just trying to connect to a database and read the values within

This works on my local PC as I'm using Windows authentication, but when I run this code in a VM I get the above error as it doesn't have the correct credentials?

Any help with this would be much appreciated!

  • "Login timeout expired" is not caused by bad credentials, it is caused by not being able to reach the server. What does `ping SERVER_NAME` say when you run it on the Ubuntu box? – Gord Thompson Nov 30 '19 at 13:17
  • Also re: `Trusted_Connection=yes` from a Linux box, see [this answer](https://stackoverflow.com/a/37702329/2144390). – Gord Thompson Nov 30 '19 at 13:23
  • @GordThompson ping SERVER_NAME returns `ping: SERVER_NAME: Temporary failure in name resolution` – John McLaren Nov 30 '19 at 14:17
  • So try using the server's IP address (something like 192.168.0.179) instead of SERVER_NAME. – Gord Thompson Nov 30 '19 at 14:20

0 Answers0