def initialize_config(): path = os.path.dirname(os.path.realpath(__file__)) fileConfig(f"{path}/config/log.ini") # fileConfig('./config/log.ini') config = ConfigHelper() return { 'base_url': config.get('server', 'base_url'), 'port': config.get('server', 'port'), 'workers': config.get('server', 'workers'), 'log_level': config.get('logging', 'level') }
def __init__(self): config_helper = ConfigHelper() dialect = config_helper.get("database", "dialect") host = config_helper.get("database", "host") port = config_helper.get("database", "port") name = config_helper.get("database", "name") username = config_helper.get("database", "username") password = config_helper.get("database", "password") # TODO: I couldn't get MySQL to work without added pymysql to the connection string # SQLAlchemy uses mysqldb by default but I couldn't find that module in PyPi self._engine = create_engine( f"{dialect}+pymysql://{username}:{password}@{host}:{port}/{name}") self.session_factory = sessionmaker(bind=self._engine) self.session = scoped_session(self.session_factory)