summaryrefslogtreecommitdiff
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
parentf0e8662a89d89f164ea95e961fe7cc37309ae822 (diff)
* database connection
-rw-r--r--.gitattributes1
-rw-r--r--conf/db.jsonbin0 -> 175 bytes
-rw-r--r--rcal/db.py11
3 files changed, 12 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..e61e4e2
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+conf/db.json filter=git-crypt diff=git-crypt
diff --git a/conf/db.json b/conf/db.json
new file mode 100644
index 0000000..1c13879
--- /dev/null
+++ b/conf/db.json
Binary files differ
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)