我在 Linux 的 Django 中有我的应用程序。和 Windows 上的 MS SQL 数据库。它们由 pyodbc\freetds 驱动程序连接。英文资料插好。我可以在 db 中看到它,但是俄语字符会导致错误:
代码:
p = Person()
# also tried u'Вася', unicode('Вася'), 'Вася'.decode('utf-8').encode('cp1251')
p.name='Вася'
p.save()
错误:
ProgrammingError: ('42000','[42000] [FreeTDS][SQL Server]The incoming tabular
data stream (TDS) protocol stream is incorrect. The stream ended unexpectedly.
(4002) (SQLExecDirectW)')
我在 odbc.ini 和 freetds.conf 中设置:
tds_version = 8.0
client charset = UTF-8
Ps 还“从 mytable 中选择 *”返回 ??????? 而不是俄罗斯字符。