这是一个创建于 3781 天前的主题,其中的信息可能已经有所发展或是发生改变。
pymysql.err.InternalError: (1267, "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='")
如下语句创建表
create table members(name varchar(40) not null primary key, password varchar(40) not null, question varchar(100) not null, answer varchar(100) not null);
查询语句,name是中文字符
cursor.execute("SELECT name FROM members WHERE name='%s'" % name)
用pymysql-0.6.2连接数据库,后面的charset="utf8"没加出现另一个错误
self.db = pymysql.connect("localhost","root","DXC","demo",charset="utf8")
如下:
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 37-40: ordinal not in range(256)
在华莽用户组也发了一遍https://groups.google.com/forum/#!topic/Python-cn/qVK95FAH0JI
3 条回复 • 2014-05-27 10:09:28 +08:00
|
|
1
openroc 2014-05-26 22:29:42 +08:00
mysql create database时是用的utf8吗?
|
|
|
2
dddd 2014-05-26 23:36:34 +08:00
@ openroc 解决了,mysql改为了utf8编码,但是又一个问题出现了,tornado的中文cookie乱码,怎么破???
|
|
|
3
cute 2014-05-27 10:09:28 +08:00
urlencode啊
|