def bayesdb_population_table(bdb, population_id):
    """Return the name of table of the population with id `id`."""
    sql = 'SELECT tabname FROM bayesdb_population WHERE id = ?'
    cursor = bdb.sql_execute(sql, (population_id,))
    try:
        row = cursor.next()
    except StopIteration:
        raise ValueError('No such population id: %r' % (repr(population_id),))
    else:
        return row[0]