def __init__(self, conn, logger=None, auto_migrate=True, **config): ''' Initialize the SQLAlchemy database driver. ''' super(SQLAlchemyAliasDriver, self).__init__(conn, **config) self.logger = logger or get_logger('SQLAlchemyAliasDriver') Base.metadata.bind = self.engine self.Session = sessionmaker(bind=self.engine) is_empty_db = is_empty_database(driver=self) Base.metadata.create_all() if is_empty_db: init_schema_version(driver=self, model=AliasSchemaVersion, version=CURRENT_SCHEMA_VERSION) if auto_migrate: self.migrate_alias_database()
def __init__( self, conn, logger=None, auto_migrate=True, index_config=None, **config ): """ Initialize the SQLAlchemy database driver. """ super().__init__(conn, **config) self.logger = logger or get_logger("SQLAlchemyIndexDriver") self.config = index_config or {} Base.metadata.bind = self.engine self.Session = sessionmaker(bind=self.engine) is_empty_db = is_empty_database(driver=self) Base.metadata.create_all() if is_empty_db: init_schema_version( driver=self, model=IndexSchemaVersion, version=CURRENT_SCHEMA_VERSION ) if auto_migrate: self.migrate_index_database()