aboutsummaryrefslogtreecommitdiff
path: root/prometheus_pgbouncer_exporter/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'prometheus_pgbouncer_exporter/utils.py')
-rw-r--r--prometheus_pgbouncer_exporter/utils.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/prometheus_pgbouncer_exporter/utils.py b/prometheus_pgbouncer_exporter/utils.py
index 7f9aae0..ea69f46 100644
--- a/prometheus_pgbouncer_exporter/utils.py
+++ b/prometheus_pgbouncer_exporter/utils.py
@@ -14,12 +14,11 @@
import psycopg2
-def get_connection(user, port, host):
+def get_connection(user=None, port=None, host=None, dbname='pgbouncer', password=None):
+ kwargs = { 'user': user, 'port': port, 'host': host, 'dbname': dbname, 'password': password }
+ kwargs = dict([(k, v) for k, v in kwargs.items() if v])
connection = psycopg2.connect(
- database='pgbouncer',
- user=user,
- port=port,
- host=host,
+ **kwargs
)
# pgbouncer does not support transactions (as it does not make sense to),