最近在使用pymssql (版本2.3.0)连接SQL Server2012遇到如下问题:
pymssql._mssql.MSSQLDatabaseException: (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (localhost)\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (localhost)\n')
使用 local windows 去认证本机的时候,会出现上述连接失败的问题。但远程连接却可以。
当使用 pymssql versions <= 2.2.7 连接正常,大于这个版本又连接失败。
看似是对pymssql版本问题,但不想改版本!!!
怎么办???拿小本记一下:
连接参数添加 tds_version="7.0" ,完美解决问题。
“
After some searching I solved the issue by setting tds_version to '7.0' as follows:
pymssql.connect(server="localhost", tds_version="7.0")
and everything works as normal again.
”
参考来源:Adaptive Server Connection Failed on Windows pymssql >=2.2.8 · Issue #860 · pymssql/pymssql · GitHub