如何在sqlite3中插入中文字符

2024年12月02日 12:45
有1个网友回答
网友(1):

第一种,设置text_factory = str
def insert():
users = ('腾讯qq', 'qq@example.com')
conn = sqlite3.connect(dbname)
conn.text_factory = str ##!!!
cursor = conn.cursor()
cursor.execute("insert into userinfo(name, email) values(?, ?)", users)
conn.commit()
cursor.close()
conn.close()
http://my.oschina.net/letiantian/blog/217770