summaryrefslogtreecommitdiff
path: root/ausbutler/db.py
blob: 353c9e0ee3974a7792b621ed902630c7951febf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

from .config import load_config


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(
            config
        )))
    return session()