python 设置mysql查询返回的数据类型为字典

方案

class DBUtil:

    def __init__(self, host, database, user, password, port):
        self.connect = pymysql.Connect(
            host=host,
            database=database,
            user=user,
            password=password,
            port=port,
            charset='utf8mb4',
            cursorclass=pymysql.cursors.DictCursor    -----此处是关键
        )
posted @ 2025-02-11 17:37  未来可期_Durant  阅读(6)  评论(0)    收藏  举报