On my computer I have two virtual machines running using VMWARE Workstation.
One Ubuntu 2.10 machine where my python (v. 3.8.10) code is running, and one Windows 10 machine where my Microsoft SQL Server is located.
I want to query data from SQL Server using Python code on my Ubuntu machine.
This is my code:
import pyodbc
server = 'xxx.xxx.xxx.xxx' <- IP address of the Windows VM
database = 'TestDB'
username = 'TestUser'
password = 'test123'
cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
cursor = cnxn.cursor()
I get this error in response:
pyodbc.OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')
I have tried using these credentials to log in to Microsoft SQL Server Management Studio and it work just fine.
Thanks for your help.
---------EDIT----------
Efter runing query xp_readerrorlog 0, 1, N'Server is listening on'
in SMS i get the following results:
LogDate | ProcessInfo | Text |
---|---|---|
2021-09-09 13:24:44.380 | spid33s | Server is listening on [ 'any' 49677]. |
2021-09-09 13:24:44.390 | spid33s | Server is listening on [ 'any' 49677]. |