python查询数据库结果返回字典格式

import pymysql
db = pymysql.connect(host='',
                     port=3306,
                     user='',
                     password='')
cursor_dict = db.cursor(cursor=pymysql.cursors.DictCursor)
sql = ''
data = cursor_dict.execute(sql)
print(data)

你可能感兴趣的:(python)