diff options
author | emkael <emkael@tlen.pl> | 2017-01-04 00:11:18 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2017-01-04 20:56:16 +0100 |
commit | 0338652f859808c108b23f2e7d9d187dd400e00e (patch) | |
tree | 0473aaec0c19a9ff5e0635e4afe1f5fa5a6dc565 /ausbutler/db.py | |
parent | 6998a5f2c027d4fd64fe802789737a35da114819 (diff) |
Database connection setup
Diffstat (limited to 'ausbutler/db.py')
-rw-r--r-- | ausbutler/db.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/ausbutler/db.py b/ausbutler/db.py new file mode 100644 index 0000000..c813b58 --- /dev/null +++ b/ausbutler/db.py @@ -0,0 +1,13 @@ +import json +from os import path + +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'))) +engine = create_engine( + "mysql://{0[user]}:{0[pass]}@{0[host]}/{0[db]}".format(config)) + +Session = sessionmaker(bind=engine) |