diff options
author | emkael <emkael@tlen.pl> | 2016-02-23 13:52:48 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-02-23 13:53:15 +0100 |
commit | b5998ad539035adb45dced86e3ef8365185cb18f (patch) | |
tree | ec8bf1b0783a81f4776d4a2cd3fcaeaf10a45d87 /rcal | |
parent | 947cf2845a23d01c070c43825662327cef7a16d0 (diff) |
* configure DB charset properly and change the way DB string is built
Diffstat (limited to 'rcal')
-rw-r--r-- | rcal/db.py | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -1,6 +1,7 @@ import json from os import path +import sqlalchemy.engine.url as url from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker @@ -13,9 +14,15 @@ class Session(object): config = json.load( open(path.join(path.dirname( path.realpath(__file__)), '..', 'conf', 'db.json'))) - db_str = "{0[type]}://{0[user]}:{0[pass]}@{0[host]}/{0[name]}".format( - config) - self.engine = create_engine(db_str) + db_str = url.URL( + drivername=config['type'], + host=config['host'], + username=config['user'], + password=config['pass'], + database=config['name'], + query={'charset': config['cset']} + ) + self.engine = create_engine(db_str, encoding=config['cset']) def get_maker(self): return sessionmaker(bind=self.engine) |