當前位置: 首頁>>代碼示例>>Python>>正文


Python session.create_engine方法代碼示例

本文整理匯總了Python中oslo_db.sqlalchemy.session.create_engine方法的典型用法代碼示例。如果您正苦於以下問題:Python session.create_engine方法的具體用法?Python session.create_engine怎麽用?Python session.create_engine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在oslo_db.sqlalchemy.session的用法示例。


在下文中一共展示了session.create_engine方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run_migrations_online

# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import create_engine [as 別名]
def run_migrations_online():
    set_mysql_engine()
    engine = session.create_engine(neutron_config.database.connection)

    connection = engine.connect()
    context.configure(
        connection=connection,
        target_metadata=target_metadata,
        version_table=alembic_migrations.VPNAAS_VERSION_TABLE
    )
    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close()
        engine.dispose() 
開發者ID:openstack,項目名稱:neutron-vpnaas,代碼行數:18,代碼來源:env.py

示例2: run_migrations_online

# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import create_engine [as 別名]
def run_migrations_online():
    set_mysql_engine()
    engine = session.create_engine(neutron_config.database.connection)

    connection = engine.connect()
    context.configure(
        connection=connection,
        target_metadata=target_metadata,
        version_table=DR_VERSION_TABLE
    )
    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close()
        engine.dispose() 
開發者ID:openstack,項目名稱:neutron-dynamic-routing,代碼行數:18,代碼來源:env.py

示例3: run_migrations_online

# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import create_engine [as 別名]
def run_migrations_online():
    set_mysql_engine()
    engine = session.create_engine(neutron_config.database.connection)

    connection = engine.connect()
    context.configure(
        connection=connection,
        target_metadata=target_metadata,
        include_object=include_object,
        version_table=L2GW_VERSION_TABLE
    )

    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close()
        engine.dispose() 
開發者ID:openstack,項目名稱:networking-l2gw,代碼行數:20,代碼來源:env.py

示例4: run_migrations_online

# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import create_engine [as 別名]
def run_migrations_online():
    set_mysql_engine()
    engine = session.create_engine(neutron_config.database.connection)

    connection = engine.connect()
    context.configure(
        connection=connection,
        target_metadata=target_metadata,
        include_object=include_object,
        version_table=ODL_VERSION_TABLE
    )

    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close()
        engine.dispose() 
開發者ID:openstack,項目名稱:networking-odl,代碼行數:20,代碼來源:env.py

示例5: run_migrations_online

# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import create_engine [as 別名]
def run_migrations_online():
    set_mysql_engine()
    engine = session.create_engine(neutron_config.database.connection)

    connection = engine.connect()
    context.configure(
        connection=connection,
        target_metadata=target_metadata,
        include_object=include_object,
        version_table=MIDONET_VERSION_TABLE
    )
    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close()
        engine.dispose() 
開發者ID:openstack,項目名稱:networking-midonet,代碼行數:19,代碼來源:env.py

示例6: run_migrations_online

# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import create_engine [as 別名]
def run_migrations_online():
    set_mysql_engine()
    engine = session.create_engine(neutron_config.database.connection)

    connection = engine.connect()
    context.configure(
        connection=connection,
        target_metadata=target_metadata,
        version_table=BGPVPN_VERSION_TABLE
    )
    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close()
        engine.dispose() 
開發者ID:openstack,項目名稱:networking-bgpvpn,代碼行數:18,代碼來源:env.py

示例7: run_migrations_online

# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import create_engine [as 別名]
def run_migrations_online():
    set_mysql_engine()
    engine = session.create_engine(neutron_config.database.connection)

    connection = engine.connect()
    context.configure(
        connection=connection,
        target_metadata=target_metadata,
        include_object=include_object,
        version_table=DF_VERSION_TABLE
    )

    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close()
        engine.dispose() 
開發者ID:openstack,項目名稱:dragonflow,代碼行數:20,代碼來源:env.py

示例8: run_migrations_online

# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import create_engine [as 別名]
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 = session.create_engine(
        get_sqlalchemy_url())
    connection = engine.connect()
    context.configure(
        connection=connection,
        target_metadata=target_metadata
    )

    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close() 
開發者ID:openstack,項目名稱:barbican,代碼行數:22,代碼來源:env.py

示例9: test_combine_params

# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import create_engine [as 別名]
def test_combine_params(self):
        with self._fixture() as ce:
            engines.create_engine(
                "mysql+pymysql://foo:bar@bat/"
                "?charset=utf8&param_file=tripleo.cnf",
                connection_parameters="plugin=sqlalchemy_collectd&"
                                      "collectd_host=127.0.0.1&"
                                      "bind_host=192.168.1.5")

        self.assertEqual(
            ce.mock_calls[0][1][0].query,
            {
                'bind_host': '192.168.1.5',
                'charset': 'utf8',
                'collectd_host': '127.0.0.1',
                'param_file': 'tripleo.cnf',
                'plugin': 'sqlalchemy_collectd'
            }
        ) 
開發者ID:openstack,項目名稱:oslo.db,代碼行數:21,代碼來源:test_sqlalchemy.py

示例10: test_combine_multi_params

# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import create_engine [as 別名]
def test_combine_multi_params(self):
        with self._fixture() as ce:
            engines.create_engine(
                "mysql+pymysql://foo:bar@bat/"
                "?charset=utf8&param_file=tripleo.cnf&plugin=connmon",
                connection_parameters="plugin=sqlalchemy_collectd&"
                                      "collectd_host=127.0.0.1&"
                                      "bind_host=192.168.1.5")

        self.assertEqual(
            ce.mock_calls[0][1][0].query,
            {
                'bind_host': '192.168.1.5',
                'charset': 'utf8',
                'collectd_host': '127.0.0.1',
                'param_file': 'tripleo.cnf',
                'plugin': ['connmon', 'sqlalchemy_collectd']
            }
        ) 
開發者ID:openstack,項目名稱:oslo.db,代碼行數:21,代碼來源:test_sqlalchemy.py

示例11: _create_engine

# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import create_engine [as 別名]
def _create_engine(connection, **engine_args):
    LOG.debug('Sql connection: please check "sql_connection" property in '
              'barbican configuration file; Args: %s', engine_args)

    engine = session.create_engine(connection, **engine_args)

    # TODO(jfwood): if 'mysql' in connection_dict.drivername:
    # TODO(jfwood): sqlalchemy.event.listen(_ENGINE, 'checkout',
    # TODO(jfwood):                         ping_listener)

    # Wrap the engine's connect method with a retry decorator.
    engine.connect = wrap_db_error(engine.connect)

    return engine 
開發者ID:openstack,項目名稱:barbican,代碼行數:16,代碼來源:repositories.py

示例12: _setUp

# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import create_engine [as 別名]
def _setUp(self):
        self._engine = session.create_engine('sqlite:///:memory:')
        self.Session = sa.orm.sessionmaker(bind=self._engine)
        self.external_id = 'EXTERNAL_ID'
        models.BASE.metadata.create_all(self._engine)
        self._load_sample_data() 
開發者ID:openstack,項目名稱:barbican,代碼行數:8,代碼來源:fixture.py

示例13: setUp

# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import create_engine [as 別名]
def setUp(self):
        super(DBManageTestCase, self).setUp()
        self.sbehaviors = secret_behaviors.SecretBehaviors(self.client)
        self.cbehaviors = container_behaviors.ContainerBehaviors(self.client)

        db_url = BCONF.sql_connection

        time.sleep(5)
        # Setup session for tests to query DB
        engine = session.create_engine(db_url)
        self.conn = engine.connect() 
開發者ID:openstack,項目名稱:barbican,代碼行數:13,代碼來源:test_db_manage.py

示例14: __init__

# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import create_engine [as 別名]
def __init__(self, db_connection, library_path, login, slot_id):
        self.dry_run = False
        self.db_engine = session.create_engine(db_connection)
        self._session_creator = scoping.scoped_session(
            orm.sessionmaker(
                bind=self.db_engine,
                autocommit=True
            )
        )
        self.crypto_plugin = p11_crypto.P11CryptoPlugin(CONF)
        self.plugin_name = utils.generate_fullname_for(self.crypto_plugin)
        self.pkcs11 = self.crypto_plugin.pkcs11
        self.session = self.pkcs11.get_session() 
開發者ID:openstack,項目名稱:barbican,代碼行數:15,代碼來源:pkcs11_migrate_kek_signatures.py

示例15: _fixture

# 需要導入模塊: from oslo_db.sqlalchemy import session [as 別名]
# 或者: from oslo_db.sqlalchemy.session import create_engine [as 別名]
def _fixture(self):
        from sqlalchemy import create_engine

        def _mock_create_engine(*arg, **kw):
            return create_engine("sqlite://")

        return mock.patch(
            "oslo_db.sqlalchemy.engines.sqlalchemy.create_engine",
            side_effect=_mock_create_engine) 
開發者ID:openstack,項目名稱:oslo.db,代碼行數:11,代碼來源:test_sqlalchemy.py


注:本文中的oslo_db.sqlalchemy.session.create_engine方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。