From a47007c7dd2eb6ad9b1a4cbb1b2c05a5bf9160c3 Mon Sep 17 00:00:00 2001 From: Christian Quest Date: Fri, 6 May 2016 15:22:31 +0200 Subject: [PATCH] postgres default connection --- backend.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/backend.py b/backend.py index a8906cd..ac8aaa0 100644 --- a/backend.py +++ b/backend.py @@ -9,9 +9,13 @@ import json import codecs def db_connect(): - db_host = os.getenv("DB_HOST","localhost") - db_password = os.getenv("POSTGRES_PASSWORD","") - db = psycopg2.connect(dbname="oedb",host=db_host,password=db_password) + try: + db = psycopg2.connect(dbname="oedb") + except: + db_host = os.getenv("DB_HOST","localhost") + db_password = os.getenv("POSTGRES_PASSWORD","") + db = psycopg2.connect(dbname="oedb",host=db_host,password=db_password) + return db def standard_headers(resp):