This topic created in 4354 days ago, the information mentioned may be changed or developed.
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 replies 2014-05-27 10:09:28 +08:00  | | div class="fr"> 1 openroc May 26, 2014 mysql create database时是用的utf8吗? |
 | | 2 dddd May 26, 2014 @ openroc 解决了,mysql改为了utf8编码,但是又一个问题出现了,tornado的中文cookie乱码,怎么破??? |
 | | 3 cute May 27, 2014 urlencode啊 |