python访问sqlite3中文数据
一个简单应用使用SQLite ("SQLite version 3.5.8") 做DBMS,
有表cfg_citycode
sqlite> .schema cfg_citycode
CREATE TABLE cfg_citycode (
code char(8) PRIMARY KEY,
name varchar(32)
);
其中name字段存放内容为中文字符
sqlite> select * from cfg_citycode limit 10;
0|国内其他
00|国际其他
001|美加地区
001242|巴哈马
001246|巴巴多斯
001264|安圭拉岛
001268|安提瓜和巴布达
001284|英属维尔京群岛
001286|安提瓜和巴布达
001340|美属维尔京群岛
...
用python编程访问:
IDLE 1.2.2
>>> import sqlite3
>>> conn = sqlite3.connect("..\\DAT\\boss.sqlite")
>>> curr = conn.cursor()
>>> curr.execute("select * from cfg_citycode limit 10;")
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
curr.execute("select * from cfg_citycode limit 10;")
OperationalError: Could not decode to UTF-8 column 'name' with text '国内其他'
>>>
I need help.