summaryrefslogtreecommitdiff
path: root/f1elo/db.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2014-10-29 15:28:32 +0100
committeremkael <emkael@tlen.pl>2014-10-29 15:28:32 +0100
commit837039ff07a1d32602788d5fcc4aff236ee53d47 (patch)
tree7381023b955ef6fa93007133f13b6eb7a9b14e19 /f1elo/db.py
parent477840592693ad3432a2d94b4bd892f0970a9f3a (diff)
* autopep8 + isort
Diffstat (limited to 'f1elo/db.py')
-rw-r--r--f1elo/db.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/f1elo/db.py b/f1elo/db.py
index 554a061..58e7a8a 100644
--- a/f1elo/db.py
+++ b/f1elo/db.py
@@ -5,13 +5,16 @@ import __main__
from sqlalchemy import create_engine, event
from sqlalchemy.orm import sessionmaker
-config = json.load(open(path.join(path.dirname(__main__.__file__), 'config', 'db.json')))
+config = json.load(
+ open(path.join(path.dirname(__main__.__file__), 'config', 'db.json')))
if config['engine'] == 'mysql':
- engine = create_engine("mysql://{0[user]}:{0[pass]}@{0[host]}/{0[db]}?charset=utf8".format(config))
+ engine = create_engine(
+ "mysql://{0[user]}:{0[pass]}@{0[host]}/{0[db]}?charset=utf8".format(config))
elif config['engine'] == 'sqlite':
engine = create_engine("sqlite:///{0[file]}".format(config))
+
def fk_pragma(conn, record):
- conn.execute('PRAGMA FOREIGN_KEYS=ON');
+ conn.execute('PRAGMA FOREIGN_KEYS=ON')
event.listen(engine, 'connect', fk_pragma)
Session = sessionmaker(bind=engine)