summaryrefslogtreecommitdiff
path: root/ausbutler/db.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-01-04 00:45:26 +0100
committeremkael <emkael@tlen.pl>2017-01-04 20:56:23 +0100
commit63ab18bb8903ddd8d88516fda450b815329ab357 (patch)
tree997a152c68106d0dc085517b066bb2c06fed671e /ausbutler/db.py
parentb231002cd6bd5df74867627576a75c510b41e1f1 (diff)
Code reformatting
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()