def get_db_connections_with_conf()

in postgresql_metrics/metrics_logic.py [0:0]


def get_db_connections_with_conf(conf):
    connections = []
    if 'databases' in conf['postgres']:
        if not conf['postgres']['databases']:
            raise Exception("no target databases defined in configuration")
        for database_name in conf['postgres']['databases']:
            connections.append(connect_to_single_db_with_conf(conf, database_name))
    elif 'database' in conf['postgres']:
        # this is here just for backward compatibility, before the databases option handled above
        connections.append(connect_to_single_db_with_conf(conf, conf['postgres']['database']))
    if not connections:
        raise Exception("could not connect to database with configuration:\n" + str(conf))
    return connections