我试图插入多种语言支持。
所以我将名字字段整理设置为utf-8 general cli。
当我在workbenck中直接运行下面的sql查询时。它插入了相同的语言。
INSERT INTO `samba`.`userprofile`(`email`,
`name`,
`pass`,`passcode`)
VALUES
('ands@gme1d22.com','ญาณทัสนะ','ana','awer');
当我尝试插入python脚本时,我插入的内容像“à¸à¸²à¸”à¸-ัสนర“
这是我的python脚本。
# -*- coding: utf-8 -*-
from gettext import gettext as _
import MySQLdb
try:
db = MySQLdb.connect("localhost","root","password","samba" )
cursor = db.cursor()
except:
print "Database Not Connected"
sys.exit(1)
query = """
INSERT INTO `samba`.`userprofile`(`email`,
`name`,
`pass`,`passcode`)
VALUES
('ands@gme1d22.com','ญาณทัสนะ','ana','awer');
"""
cursor.execute(query)
db.commit()