def name_fields(cursor, records):
    """
    Take a cursor and a list of records fetched with that cursor, then return a
    list of dictionaries (one for each record) whose keys are column names and
    values are records' values.

    :param cursor: cursor used to execute the query
    :param records: list returned by fetch*()
    """
    result = []
    for record in records:
        record_dict = {}
        for i in range(len(record)):
            record_dict[cursor.description[i][0]] = record[i]
        result.append(record_dict)
    return result
