我想使用sqlalchemy查询一个列名为u'F\u0151biztos\xedt\xf3'
的mssql数据库(我使用的是pymssql驱动程序)。我已经将这个列名映射到一个名为'Fobiztosito'
的ascii列键。你知道吗
现在我的表的列显示为
In [32]: Biztosito.__table__.c.Fobiztosito
Out[32]: Column('F\u0151biztos\xedt\xf3', VARCHAR(length=50, collation=u'Hungarian_Technical_CI_AS'), table=<BIZTOSIT>, key='Fobiztosito')
但对此列的筛选失败(此处为完整堆栈跟踪:http://pastebin.com/G20T6s92):
In [38]: session.query(Biztosito.pk).filter(Biztosito.Fobiztosito=='AHB').all()
<type 'str'>: (<type 'exceptions.UnicodeEncodeError'>, UnicodeEncodeError('ascii', u'params dictionary did not contain value for placeholder: F\u0151biztos\xedt\xf3_1', 58, 59, 'ordinal not in range(128)'))
这是查询语句
In [37]: print session.query(Biztosito.pk).filter(Biztosito.Fobiztosito=='AHB').statement
SELECT [BIZTOSIT].[BiztKod]
FROM [BIZTOSIT]
WHERE [BIZTOSIT].[F\u0151biztos\xedt\xf3] = %(F\u0151biztos\xedt\xf3_1)s
有什么想法吗?你知道吗
为什么不使用utf-8排序规则呢?我在用俄语工作,每当我需要使用Unicode文本、符号或查询表时,我都只使用utf-8、Unicode或UnicodeText。你知道吗
相关问题 更多 >
编程相关推荐