# 返回字典方法,传入一个执行过查询sql语句的cursor对象
def sqlite_dict(obj_cursor):
text = {}
list = []
# 获取obj_cursor的信息集
data_set = obj_cursor.fetchall()
# 将信息遍历
for data in data_set:
# 使用cursor游标的description方法,得到数据库的每一列的信息
# 将data信息与其拼接为字典,并存放入列表中
# 其实还有个数据库方法获取列名信息:PRAGMA TABLE INOF([表名])
for s, x in enumerate(obj_cursor.description):
text[x[0]] = data[s]
# 若是多个引用值,list.append(str(text))
list.append(text)
# 返回列表
return list