python mysql 查询字典类型
常见的类型,本次使用DictCursor
具体代码
'''
@Author: Jeff.zheng
@Date : 2024-04-02
@Desc : 修改游标
'''import pymysqlif __name__ == '__main__':connection = connection = pymysql.connect(host="192.168.10.163", user="root", password="root", db="softide_cloud3",charset='utf8mb4')cursor = connection.cursor()cursor.close()# 修改游标connection.cursorclass = pymysql.cursors.DictCursorcursor = connection.cursor()try:query = "SELECT * FROM tb_app_info"cursor.execute(query)rows = cursor.fetchall()for row in rows:# 根据你的表结构处理每一行数据print(row)finally:connection.close()