当前位置:Gxlcms > 数据库问题 > mysql中将数据库返回结果转为dict

mysql中将数据库返回结果转为dict

时间:2021-07-01 10:21:17 帮助过:41人阅读

self.conn = pymysql.connect(
host=‘xxx‘,
port=3806,
user=‘root‘,
passwd=str(123456),
db = ‘test‘,
charset = "utf8"

)

结果:{‘id‘: 1, ‘name‘: ‘11‘}

self.conn = pymysql.connect(

    host=‘xxx‘,
port=3806,
user=‘root‘,
passwd=str(123456),
db = ‘test‘,
charset = "utf8",
cursorclass=pymysql.cursors.DictCursor

)

mysql中将数据库返回结果转为dict

标签:root   test   sel   xxx   font   pass   dict   ORC   passwd   

人气教程排行