Skip to content Skip to sidebar Skip to footer

Unable To Connect To Database : Pyodbc

I'm trying to connect to an MSSQL database from python on Linux . Whenever I try to connect to database through python . I get the following error : >>> import pyodbc &g

Solution 1:

Did you try the following connection string. I have the TDS Driver Version 8.0, and the following connection strings works on my system:

username = "domain\\user"connection_string = "DRIVER={FreeTDS};SERVER=xxxx;PORT=xx;DATABASE=xxxx;UID=%s;PWD=xxx;CHARSET=UTF8;TDS_Version=8.0" % username

Solution 2:

Somehow when connecting to Microsoft SQL Server 2008 I needed to add option ;PORT=1433 to connection string as suggested by Tushar. 1433 is the default port and the connection worked fine without explicit port definition to another server.

Post a Comment for "Unable To Connect To Database : Pyodbc"