Sqlcmd can connect to old SQL Server 2005, but connection string pyodbc with Driver 18 from Microsoft does not work

50 views Asked by At

I need to connect with a python to an old legacy SQL Server database (2005) from a Windows 11 laptop

I can access the server and login with sqlcmd.

The following statement works to connect:

sqlcmd -S <IP>,<PORT> -N disable -C -U <UID> -P <PWD>

However the connection string does not work via pyodbc

DRIVER=ODBC Driver 18 for SQL Server;SERVER=10.101.6.197,1433;UID=<UID>;PWD=<PWD>;DATABASE=<DATABASE>;Encrypt=no;

I tried all drivers also 13 and 17. Anybody has an idea how to have the equivalent of sqlcmd as a connection string.

  • Python version 3.12
  • Pyodbc: 5.1.0

Different drivers tried.

Encrypt=disabled (not recognize)
Trusted_Connection=yes

It seems to be a TLS version issue but somehow with connection string I can not completely disable encryption. Everything is behind VPN connections so security wise and the server is only occasional spun up when needed so that disabled encryption is acceptable in this edge case.

0

There are 0 answers