def bayesdb_variable_numbers(bdb, population_id, generator_id):
    """Return a list of the numbers of columns modeled in `population_id`."""
    cursor = bdb.sql_execute('''
        SELECT colno FROM bayesdb_variable
            WHERE population_id = ?
                AND (generator_id IS NULL OR generator_id = ?)
            ORDER BY colno ASC
    ''', (population_id, generator_id))
    return [colno for (colno,) in cursor]