def dictfetchall ( cursor : Cursor ) -> List [ Dict [ str , Any ] ] : columns = get_fieldnames_from_cursor ( cursor ) return [ OrderedDict ( zip ( columns , row ) ) for row in cursor . fetchall ( ) ]
python return ordereddict from db cursor
Return all rows from a cursor as a list of : class : OrderedDict objects .
def dictfetchall(cursor: Cursor) -> List[Dict[str, Any]]:
    """
    Return all rows from a cursor as a list of :class:`OrderedDict` objects.

    Args:
        cursor: the cursor

    Returns:
        a list (one item per row) of :class:`OrderedDict` objects whose key are
        column names and whose values are the row values
    """
    columns = get_fieldnames_from_cursor(cursor)
    return [
        OrderedDict(zip(columns, row))
        for row in cursor.fetchall()
    ]