代码中找出来的,先记下,以后试用。原始查询转字典

def get_dictresult(cursor):
    """
    Column name is always lower case.
    :param cursor:
    :return:
    """
    if cursor.description is None:
        return []
    cols = [c[0].lower() for c in cursor.description]
    data = [dict(zip(cols, row)) for row in cursor.fetchall()]
    return data

猜你喜欢

转载自blog.csdn.net/weixin_42068117/article/details/81533095