插入(unicode?)文本到sqlite3数据库时出错
我有一个sqlite3数据库,我正在从一个db2数据库里填充数据。当我运行以下代码时,出现了一个错误:
for row in db2_connection.execute(query):
sqlite3_connection.execute("INSERT INTO MY_TABLE VALUES (?, ?, ?)", row)
这是错误信息:
File "example.py", line 72, in load_micr_db
sqlite3_connection.execute("INSERT INTO MY_TABLE VALUES (?, ?, ?)", row)
sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a
text_factory that can interpret 8-bit bytestrings (like text_factory = str).
It is highly recommended that you instead just switch your application to
Unicode strings.
这听起来像是很好的建议,但我不知道该怎么做。怎么才能“把我的应用程序切换到Unicode字符串”呢?
我正在使用Python 2.6,pyodbc
来查询db2 9,还有sqlite3
。