def config_database_option(config, key, dbname=None, getbool=False):
    """ Get database-level config option """
    if config is None:
        return None
    if dbname is None:
        return None
    section = 'database "{}"'.format(dbname)
    if not section in config:
        return None
    return config[section].get(key, None) if not getbool else config[section].getboolean(key)