2017-08-09 885 views
1

我嘗試連接到SQL Server 2012的分貝python3(3.5.3)庫pymssql(2.1.3) 「無法識別歸類」 這個錯誤發生了:pymssql連接失敗

conn = pymssql.connect(host="192.168.xxx.xxx", user="wbs", password="[email protected]", database="mydb") 
Traceback (most recent call last): 
    File "pymssql.pyx", line 635, in pymssql.connect (pymssql.c:10734) 
    File "_mssql.pyx", line 1902, in _mssql.connect (_mssql.c:21821) 
    File "_mssql.pyx", line 637, in _mssql.MSSQLConnection.__init__ (_mssql.c:6581) 
    File "_mssql.pyx", line 1630, in _mssql.maybe_raise_MSSQLDatabaseException (_mssql.c:17524) 
_mssql.MSSQLDatabaseException: (4075, b'DB-Lib error message 20018, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\nDB-Lib error message 20018, severity 14:\nGeneral SQL Server error: Check messages from the SQL Server\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (192.168.100.249:1433)\n') 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "pymssql.pyx", line 641, in pymssql.connect (pymssql.c:10824) 
pymssql.OperationalError: (4075, b'DB-Lib error message 20018, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\nDB-Lib error message 20018, severity 14:\nGeneral SQL Server error: Check messages from the SQL Server\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (192.168.100.249:1433)\n') 

和MSSQL錯誤有一個日誌吧:

The USE database statement failed because the database collation %.*ls is not recognized by older client drivers. Try upgrading the client operating system or applying a service update to the database client software, or use a different collation. See SQL 

回答

1

默認情況下,PIP從靜態鏈接到freetds的0.95二進制輪(.whl)文件安裝pymssql 2.1.3。不幸的是,FreeTDS的舊版本不知道如何使用一些不常用的SQL Server排序規則。例如,已知Persian_100_CI_AI會導致類似於FreeTDS 0.9x(參考:here)中描述的錯誤。

freetds的1.x中對那些歸類更好的支持,所以其中一個方案是爲您安裝freetds的(目前1.00.51)最新的穩定版本,然後建立從最新的源pymssql上GitHub

或者,您可以嘗試使用pyodbc與當前版本的Microsoft SQL Server ODBC驅動程序。

+0

非常感謝,我編譯和安裝freetds最新的穩定和pimssql最新從git,一切都OK! – alireza