(1064, "You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for
the right syntax to use near 'a.txn_id=b.dict_id and
(b.dict_name like '%\xe5\x86\xb2\xe6\xad\xa3'
or b.dict_name like '%\xe9\x80\x80\xe8\xb4\xa7' at line 1")
所有的数据库都是设置成utf8了,文件也是utf8就是搞不清楚哪里错,py使用如下
cursor = connection.cursor()
cursor.execute(
"select (select c.org_name from sys_org c where c.mid=a.mid and c.id like %s) as org_name,"+
"a.pan,a.txn_amt,(select d.dict_name from sys_dict d where d.dict_type='sys_tran_appl' and a.appl_id=d.dict_id) as appl_name,"+
"b.dict_name,a.txn_date,a.txn_time "+
"from trans a,sys_dict b"+
"where a.txn_id=b.dict_id and (b.dict_name like %s or b.dict_name like %s) "+
"and and CONCAT(txn_date,' ',txn_time) between %s and %s "+
"order by CONCAT(txn_date,' ',txn_time) desc ",
[user.sys_org_id + "%",u'%冲正',u'%退货',min_datetime, max_datetime]
)
cursor.execute("SET NAMES 'utf8'; ")
fetchall = cursor.fetchall()