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

Posted 鱼的记忆

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql中将数据库返回结果转为dict相关的知识,希望对你有一定的参考价值。

结果:(1, ‘11‘)

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的主要内容,如果未能解决你的问题,请参考以下文章