예제 #1
0
    def test_get_database(self):
        database_url = 'sqlite:///:memory:'

        # Default database via template configuration file.
        db = config.get_database(database_url=database_url)
        self.assertEqual(db.__class__.__name__, 'CombinedDatabase')
        self.assertIsInstance(db, Database)
        self.assertNotIsInstance(db, JCMTPart)

        # Get database via plain facility name.
        db = config.get_database(database_url=database_url,
                                 facility_spec='JCMT')
        self.assertEqual(db.__class__.__name__, 'CombinedDatabase')
        self.assertIsInstance(db, Database)
        self.assertIsInstance(db, JCMTPart)

        # Get database via plain facility name.
        db = config.get_database(
            database_url=database_url,
            facility_spec='hedwig.facility.jcmt.view.JCMT')
        self.assertEqual(db.__class__.__name__, 'CombinedDatabase')
        self.assertIsInstance(db, Database)
        self.assertIsInstance(db, JCMTPart)
예제 #2
0
파일: env.py 프로젝트: ryszard-ps/hedwig
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.

    """

    connectable = get_database()._engine

    with connectable.connect() as connection:
        context.configure(connection=connection,
                          target_metadata=target_metadata,
                          include_object=include_object)

        with context.begin_transaction():
            context.run_migrations()
예제 #3
0
파일: env.py 프로젝트: eaobservatory/hedwig
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.

    """

    connectable = get_database()._engine

    with connectable.connect() as connection:
        context.configure(
            connection=connection,
            target_metadata=target_metadata,
            include_object=include_object
        )

        with context.begin_transaction():
            context.run_migrations()