I am trying to connect to MS SQL Server using pyodbc from a remote machine running Ubuntu 16.04.
import pyodbc
conn = pyodbc.connect(r\'DRIVER
Microsoft's ODBC drivers for SQL Server do not use a PORT= parameter. The port number, if any, is appended to the server name/IP with a comma, e.g.,
SERVER=xxxTest-SRV,51333;
I ran into the same kind of issue, but my scenario is connecting to SQL server hosted on ec2 instance through AWS Lambda function using PyOdbc module. For me, replacing the host name with IP address of ec2 instance fixed it.
I found out that it was not able to resolve dns. So if any of the above steps didn't work for you, please try using the ip address and comment here