summaryrefslogtreecommitdiff
path: root/rcal
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-02-19 09:57:14 +0100
committeremkael <emkael@tlen.pl>2016-02-19 09:57:14 +0100
commitdc06dd7b81d0fe8430c46b8d2d4431d473b0f633 (patch)
tree5ac0c11e0826abb9559922808718f875cb439799 /rcal
parentf0e8662a89d89f164ea95e961fe7cc37309ae822 (diff)
* database connection
Diffstat (limited to 'rcal')
-rw-r--r--rcal/db.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/rcal/db.py b/rcal/db.py
new file mode 100644
index 0000000..3e74c4e
--- /dev/null
+++ b/rcal/db.py
@@ -0,0 +1,11 @@
+from sqlalchemy import create_engine
+from sqlalchemy.orm import sessionmaker
+import json, __main__
+from os import path
+
+config = json.load(
+ open(path.join(path.dirname(__main__.__file__), 'conf', 'db.json')))
+engine = create_engine(
+ "{0[type]}://{0[user]}:{0[pass]}@{0[host]}/{0[name]}?{0[opts]}".format(config))
+
+Session = sessionmaker(bind=engine)