aboutsummaryrefslogtreecommitdiffstats
path: root/python/db.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/db.py')
-rw-r--r--python/db.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/python/db.py b/python/db.py
index 760344f1..2c830ab4 100644
--- a/python/db.py
+++ b/python/db.py
@@ -1,6 +1,7 @@
import psycopg2
from psycopg2.extras import DictCursor
from psycopg2 import IntegrityError
+from sqlalchemy import create_engine
def dbconn(dbname):
if dbname == 'etdb':
@@ -13,6 +14,11 @@ def dbconn(dbname):
host="debian",
cursor_factory=DictCursor)
+def dbengine(dbname):
+ uri = "postgresql://{0}@debian/{1}".format(dbname[:-2] + '_user',
+ dbname)
+ return create_engine(uri)
+
def with_connection(dbname):
def decorator(f):
conn = dbconn(dbname)