def _get_data(conn, sql_class, columns_to_select, column_to_value_map):
    """
    Get first available row based on a list of column_name:value pairs.

    Return the data as a dictionary.
    """
    columns = ', '.join(columns_to_select)
    column_to_value_clause = 'AND '.join(
        ['%s = $$%s$$' % (k, v) for k, v in column_to_value_map.items()]
    )
    query = 'SELECT {columns} FROM {table_name} WHERE {column_to_value_clause};'.format(
        columns=columns,
        table_name=sql_class.__tablename__,
        column_to_value_clause=column_to_value_clause)
    results = conn.execute(query)
    data = results.first()
    if data:
        return dict(data)
    return {}