def _translate_row(row, key_by_index):
    """
    SQL queries return results as lists of columns. This function translates a
    row into a dictionary of column_name -> value.

    >>> _translate_row([123, 'some-foo-value'], ['_count', 'foo'])
    {'_count': 123, 'foo': 'some-foo-value'}
    """
    return {key_by_index[i]: col for i, col in enumerate(row)}