Mercurial > libervia-pubsub
diff sat_pubsub/tap.py @ 328:ae37289007c3
fixed database config : None values can't be used anymore
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 03 Mar 2017 08:35:34 +0100 |
parents | 8496af26be45 |
children | 83122f15b993 |
line wrap: on
line diff
--- a/sat_pubsub/tap.py Wed Mar 09 10:41:38 2016 +0100 +++ b/sat_pubsub/tap.py Fri Mar 03 08:35:34 2017 +0100 @@ -108,15 +108,24 @@ from twisted.enterprise import adbapi from sat_pubsub.pgsql_storage import Storage from psycopg2.extras import NamedTupleConnection + keys_map = { + 'dbuser': 'user', + 'dbpass': 'password', + 'dbname': 'database', + 'dbhost': 'host', + 'dbport': 'port', + } + kwargs = {} + for config_k, k in keys_map.iteritems(): + v = config.get(config_k) + if v is None: + continue + kwargs[k] = v dbpool = adbapi.ConnectionPool('psycopg2', - user=config['dbuser'], - password=config['dbpass'], - database=config['dbname'], - host=config['dbhost'], - port=config['dbport'], cp_reconnect=True, client_encoding='utf-8', connection_factory=NamedTupleConnection, + **kwargs ) st = Storage(dbpool) elif config['backend'] == 'memory':