diff options
author | emkael <emkael@tlen.pl> | 2017-05-04 23:19:14 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2017-05-09 02:51:36 +0200 |
commit | 9ad496966ab94c37cbf4208ec1fd39257cb60410 (patch) | |
tree | 4bbb7bce3d4eb598f723e76211c9f29c5feb0635 /ausbutler | |
parent | 557569d76e9ccaaef9df4b6d49cb14a55b5e4980 (diff) |
Verbose DB name read
Diffstat (limited to 'ausbutler')
-rw-r--r-- | ausbutler/db.py | 6 | ||||
-rw-r--r-- | ausbutler/interface.py | 5 | ||||
-rw-r--r-- | ausbutler/model.py | 3 | ||||
-rw-r--r-- | ausbutler/tour_config.py | 2 |
4 files changed, 11 insertions, 5 deletions
diff --git a/ausbutler/db.py b/ausbutler/db.py index 94f07de..353c9e0 100644 --- a/ausbutler/db.py +++ b/ausbutler/db.py @@ -4,9 +4,11 @@ from sqlalchemy.orm import sessionmaker from .config import load_config -def get_session(): +def get_session(config=None): + if config is None: + config = load_config('db') session = sessionmaker(bind=create_engine( "mysql+mysqlconnector://{0[user]}:{0[pass]}@{0[host]}/{0[db]}?charset=utf8".format( - load_config('db') + config ))) return session() diff --git a/ausbutler/interface.py b/ausbutler/interface.py index 052d910..984b59b 100644 --- a/ausbutler/interface.py +++ b/ausbutler/interface.py @@ -8,6 +8,7 @@ from sqlalchemy import text from sqlalchemy.exc import ProgrammingError from .butler import cutoff, get_line, get_opponents, get_room, normalize, get_old_normbutler +from .config import load_config from .db import get_session from .model import AusButler, Butler from .tour_config import Constants, Translations @@ -16,7 +17,9 @@ from .tour_config import Constants, Translations class Interface(object): def __init__(self, config): - self.session = get_session() + db_config = load_config('db') + print 'Tournament name: %s' % (db_config['db']) + self.session = get_session(db_config) self.config = config self.translation = Translations() self.template = Environment(loader=FileSystemLoader('template')) diff --git a/ausbutler/model.py b/ausbutler/model.py index 69447ff..7d3539c 100644 --- a/ausbutler/model.py +++ b/ausbutler/model.py @@ -4,10 +4,11 @@ from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship from sqlalchemy.types import Float, Integer, String +from .config import load_config from .db import get_session Base = declarative_base() -session = get_session() +session = get_session(load_config('db')) class Team(Base): diff --git a/ausbutler/tour_config.py b/ausbutler/tour_config.py index 1edb259..755bac9 100644 --- a/ausbutler/tour_config.py +++ b/ausbutler/tour_config.py @@ -2,7 +2,7 @@ from .config import load_config from .db import get_session from .model import Parameters, Translation -session = get_session() +session = get_session(load_config('db')) class Translations(object): |