def test_load_table(self): connection = api.get_engine() table_name = 'shares' actual_result = utils.load_table(table_name, connection) self.assertIsNotNone(actual_result) self.assertEqual(table_name, actual_result.name)
def version(): """Current database version. :returns: Database version :rtype: string """ engine = db_api.get_engine() with engine.connect() as conn: context = alembic_migration.MigrationContext.configure(conn) return context.get_current_revision()
def run_migrations_online(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ engine = db_api.get_engine() connection = engine.connect() target_metadata = db_models.ManilaBase.metadata context.configure(connection=connection, target_metadata=target_metadata) # pylint: disable=E1101 try: with context.begin_transaction(): # pylint: disable=E1101 context.run_migrations() # pylint: disable=E1101 finally: connection.close()
def run_migrations_online(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ engine = db_api.get_engine() connection = engine.connect() target_metadata = db_models.ManilaBase.metadata # pylint: disable=no-member context.configure(connection=connection, target_metadata=target_metadata) try: with context.begin_transaction(): context.run_migrations() finally: connection.close()
def db_version(): """Display the current database version.""" return IMPL.db_version(db_api.get_engine(), MIGRATE_REPO, INIT_VERSION)
def db_sync(version=None): """Migrate the database to `version` or the most recent version.""" return IMPL.db_sync(db_api.get_engine(), MIGRATE_REPO, version=version, init_version=INIT_VERSION)