【发布时间】:2015-04-15 22:25:08
【问题描述】:
我正在尝试在 python 2.7(windows) 中运行以下命令,但它给了我一个错误:
ProgrammingError: 你不能使用 8 位字节串,除非你使用 text_factory 可以解释 8 位字节字符串(如 text_factory = 字符串)。强烈建议您将应用程序切换为 Unicode 字符串。
#!/usr/bin/python
# -*- encoding: utf-8-*-
import sqlite3;
db = sqlite3.connect('db.sqlite3')
cursor = db.cursor()
cursor.execute('INSERT INTO X(id,a,b) VALUES(?,?,?)', (999998,"ą---ź---ć---ó---ęĘ","ssf"))
cursor.execute('SELECT * FROM X where id = 999998')
for row in cursor:
print row
db.commit()
db.close()
如何将这些字符串(“ąźć” = 波兰符号)插入到我的 sqlite 数据库中?
【问题讨论】:
标签: python python-2.7 sqlite