From dc06dd7b81d0fe8430c46b8d2d4431d473b0f633 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 19 Feb 2016 09:57:14 +0100 Subject: * database connection --- rcal/db.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 rcal/db.py (limited to 'rcal') 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) -- cgit v1.2.3