毫无头绪,百度出我想要的东西了,记录一下。
import sqlite3 def dict_factory(cursor, row): d = {} for idx, col in
enumerate(cursor.description): d[col[0]] = row[idx] return d con =
sqlite3.connect("ChineseCharactersLite.db") #打开数据库 con.row_factory =
dict_factory c = con.cursor() # conn =
sqlite3.connect("ChineseCharactersLite.db") # c = conn.cursor()
c.execute("select name from sqlite_master ") # """select name from
sqlite_master where type='table' order by name""" output = c.fetchall() print
(output)
这时候输出一些东西,例如我加载的数据库输出
[{'name': 'CharacterInfo'}, {'name': 'sqlite_sequence'}, {'name': 'Phrases'}]
这时候换成我们想读取的东西,例如
c.execute("select * from Phrases") output = c.fetchall()
output长这样: