def dict_factory(cursor, row):
    """
    Super simple function to convert a row to a dict.
    Using meta-data (description) from the cursor. we'll
    make a dict, populate it, and return it.
    """
    d = {}
    for idx, col in enumerate(cursor.description):
        d[col[0]] = row[idx]
    return d