pymysql fetchall 查询结果返回字典

import pymysql
from pymysql.cursors import DictCursor

connect2 = pymysql.connect(
   host='111.111.111.111',
   port=3306,
   db='dbname',
   user='root',
   passwd='123',
   charset='utf8'
)
cursor2 = connect2.cursor(DictCursor)  # cursor有参数可传入,使结果得到字典格式,而非元组

你可能感兴趣的:(python,pymysql)