summaryrefslogtreecommitdiff
path: root/ausbutler/db.py
diff options
context:
space:
mode:
Diffstat (limited to 'ausbutler/db.py')
-rw-r--r--ausbutler/db.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/ausbutler/db.py b/ausbutler/db.py
index a53a273..940c69d 100644
--- a/ausbutler/db.py
+++ b/ausbutler/db.py
@@ -1,14 +1,15 @@
import json
from os import path
-from sqlalchemy import create_engine, event
+from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
import __main__
-config = json.load(
- open(path.join(path.dirname(__main__.__file__), 'config', 'db.json')))
-engine = create_engine(
- "mysql://{0[user]}:{0[pass]}@{0[host]}/{0[db]}".format(config))
-
-Session = sessionmaker(bind=engine)
+def get_session():
+ session = sessionmaker(bind=create_engine(
+ "mysql://{0[user]}:{0[pass]}@{0[host]}/{0[db]}".format(
+ json.load(open(
+ path.join(path.dirname(__main__.__file__), 'config', 'db.json')
+ )))))
+ return session()