def dict_fetch_all(cursor):
    """
    Return all rows from a cursor as a dict.
    By default, the Python DB API will return results without their field names, which means you end up with a
    list of values, rather than a dict. At a small performance and memory cost, we can return results as a
    dict.

    Using Normal Cursor -
    >>> cursor.execute("SELECT id, parent_id FROM test LIMIT 2");
    >>> cursor.fetchall()
    ((54360982, None), (54360880, None))

    Using dict_fetch_all method -
    >>> cursor.execute("SELECT id, parent_id FROM test LIMIT 2");
    >>> dictfetchall(cursor)
    [{'parent_id': None, 'id': 54360982}, {'parent_id': None, 'id': 54360880}]
    """
    columns = [col[0] for col in cursor.description]
    return [
        dict(zip(columns, row))
        for row in cursor.fetchall()
    ]