aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/db.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/python/db.py b/python/db.py
index 46c302be..f14bd670 100644
--- a/python/db.py
+++ b/python/db.py
@@ -37,8 +37,9 @@ def dbconn(dbname):
user_name = dbname[:-2] + '_user'
return psycopg2.connect(database=dbname,
user=user_name,
- host="debian",
- cursor_factory=DictCursor)
+ host=os.environ.get("PGHOST", "debian"),
+ cursor_factory=DictCursor,
+ sslmode='require')
def dbengine(dbname):
if dbname in ['rmbs_model', 'corelogic']:
@@ -46,8 +47,9 @@ def dbengine(dbname):
host="debian", database=dbname,
query={'option_files': os.path.expanduser('~/.my.cnf')})
else:
- uri = "postgresql://{0}@debian/{1}".format(dbname[:-2] + '_user',
- dbname)
+ uri = URL(drivername="postgresql",
+ host=os.environ.get("PGHOST", "debian"),
+ username=dbname[:-2] + '_user')
return create_engine(uri, paramstyle="format")
def with_connection(dbname):