Answer the question
In order to leave comments, you need to log in
How to fix bugs in error messages in pyodbc/pymssql?
By themselves, Cyrillic characters are normally displayed, but in error messages (both in Python IDLE and in cmd.exe) in:
1) pymssql:
Traceback (most recent call last):
File "mypymssql.py", line 9, in <module>
database='SOVCOMBANK2'
File "pymssql.pyx", line 641, in pymssql.connect (pymssql.c:10824)
pymssql.OperationalError: (18456, b'\xd0\x9e\xd1\x88\xd0\xb8\xd0\xb1\xd0\xba\xd0\xb0 \xd0\xb2\xd1\x85\xd0\xbe\xd0\xb4\xd0\xb0 \xd0\xbf\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8f "nrv99".DB-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 (ASUSU38N\\SQLEXPRESS2012)\n')
Traceback (most recent call last):
File "mypyodbc.py", line 9, in <module>
""")
pyodbc.ProgrammingError: ('42S02', '[42S02] [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]������������ ��� ������� "CLIENTS". (208) (SQLExecDirectW)')
Answer the question
In order to leave comments, you need to log in
The question was asked more than two years ago, and yet today I also received a short description of the error from the Windows MSSQL server. The problem was solved by encoding and decoding the string:
try:
conn = pyodbc.connect(...)
except Exception as err:
print(err.args[1].encode("cp1252").decode("cp1251"))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question