class __OnlyApp(object): """ Class method to create database """ def __init__(self, debug): """Initialize default connection to a database""" dict_config = Config.get_config() self.__engine = create_engine("sqlite:///%s/%s" % (dict_config["database_path"], dict_config["database_name"] ), echo=debug ) Base.metadata.bind = self.__engine Base.metadata.create_all(self.__engine) plugin = sqlalchemy.Plugin(self.__engine, Base.metadata, create=True) self._app = Bottle() self._app.install(plugin) @property def server(self): """Get session""" return self._app
def __init__(self, debug): """Initialize default connection to a database""" dict_config = Config.get_config() self.__engine = create_engine("sqlite:///%s/%s" % (dict_config["database_path"], dict_config["database_name"] ), echo=debug ) Base.metadata.bind = self.__engine Base.metadata.create_all(self.__engine) plugin = sqlalchemy.Plugin(self.__engine, Base.metadata, create=True) self._app = Bottle() self._app.install(plugin)