一.返回值为字典形式
原[(1, “小明”), (2, “小红”)]
需求[{“id”:1, “name”:“小明”},{“id”:2, “name”:“小红”}]
百度后思路
- 驱动方法: https://www.jb51.net/article/94024.htm cursor.description()
- sql语句 : http://www.hangge.com/blog/cache/detail_1454.html
PRAGMA table_info([employee]);
import sqlite3
connect = sqlite3.connect("testsqlite.db")
cursor = connect.cursor()
cursor.execute(" select * from employee; ")
employees = cursor.fetchall()
print(employees) # [(1, '小明', '男', '13600000000')]