标签:mysq sql查询 hal connect nec exec close sel fetch
使用:pymysql.cursors.DictCursor
直接上代码
import pymysql
db = pymysql.connect(host = "host", user = "user", password = "password", database = "database")
cursor = db.cursor(pymysql.cursors.DictCursor)
sql = "SELECT `id`,`name` FROM `student`;"
cursor.execute(sql)
data_list = cursor.fetchall()
cursor.close()
db.close()
标签:mysq sql查询 hal connect nec exec close sel fetch
原文地址:https://www.cnblogs.com/mrzhao520/p/14888251.html