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


Python sqlalchemy.engine_from_config方法代碼示例

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


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

示例1: run_migrations_online

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import engine_from_config [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.

    """
    connectable = engine_from_config(
        config.get_section(config.config_ini_section),
        prefix="sqlalchemy.",
        poolclass=pool.NullPool,
    )

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

        with context.begin_transaction():
            context.run_migrations() 
開發者ID:HTTP-APIs,項目名稱:hydrus,代碼行數:22,代碼來源:env.py

示例2: run_migrations_online

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import engine_from_config [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.

    """
    db_url = os.environ['DRYDOCK_DB_URL']

    connectable = engine_from_config(
        config.get_section(config.config_ini_section),
        prefix='sqlalchemy.',
        poolclass=pool.NullPool,
        url=db_url)

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

        with context.begin_transaction():
            context.run_migrations() 
開發者ID:airshipit,項目名稱:drydock,代碼行數:23,代碼來源:env.py

示例3: run_migrations_online

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import engine_from_config [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.

    """
    connectable = engine_from_config(
        config.get_section(config.config_ini_section),
        prefix="sqlalchemy.",
        poolclass=pool.NullPool,
        connect_args={'options': f'-c search_path={_app_config.POSTGRES_SCHEMA}'}
    )

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

        with context.begin_transaction():
            context.run_migrations() 
開發者ID:everyclass,項目名稱:everyclass-server,代碼行數:23,代碼來源:env.py

示例4: run_migrations_online

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import engine_from_config [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 = engine_from_config(
                config.get_section(config.config_ini_section),
                prefix='sqlalchemy.',
                poolclass=pool.NullPool)

    connection = engine.connect()
    context.configure(
                connection=connection,
                target_metadata=target_metadata
                )

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

示例5: run_migrations_online

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import engine_from_config [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.

    """
    configuration = config.get_section(config.config_ini_section)
    configuration['sqlalchemy.url'] = os.environ['HAMMER_DATABASE_URL']
    connectable = engine_from_config(
        configuration,
        prefix="sqlalchemy.",
        poolclass=pool.NullPool,
    )

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

        with context.begin_transaction():
            context.run_migrations() 
開發者ID:asharov,項目名稱:git-hammer,代碼行數:24,代碼來源:env.py

示例6: run_migrations_online

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import engine_from_config [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.

    """
    connectable = engine_from_config(
        config.get_section(config.config_ini_section),
        prefix='sqlalchemy.',
        poolclass=pool.NullPool)

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

        with context.begin_transaction():
            context.run_migrations() 
開發者ID:lablup,項目名稱:backend.ai-manager,代碼行數:22,代碼來源:env.py

示例7: run_migrations_online

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import engine_from_config [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.

	"""
	connectable = engine_from_config(
		config.get_section(config.config_ini_section),
		prefix='sqlalchemy.',
		poolclass=pool.NullPool)

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

		with context.begin_transaction():
			context.run_migrations() 
開發者ID:fake-name,項目名稱:ReadableWebProxy,代碼行數:24,代碼來源:env.py

示例8: run_migrations_online

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import engine_from_config [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 = engine_from_config(
        config.get_section(config.config_ini_section),
        prefix='sqlalchemy.',
        poolclass=pool.NullPool
    )

    connection = engine.connect()
    context.configure(
        connection=connection,
        target_metadata=target_metadata,
        compare_type=True
    )

    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close() 
開發者ID:RiotGames,項目名稱:cloud-inquisitor,代碼行數:27,代碼來源:env.py

示例9: run_migrations_online

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import engine_from_config [as 別名]
def run_migrations_online():
    engine = engine_from_config(
        config.get_section(config.config_ini_section),
        prefix="sqlalchemy.",
        poolclass=pool.NullPool,
    )

    connection = engine.connect()
    context.configure(
        connection=connection, target_metadata=target_metadata, compare_type=True
    )

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

示例10: run_migrations_online

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import engine_from_config [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.

    """
    connectable = engine_from_config(
        config.get_section(config.config_ini_section),
        prefix="sqlalchemy.",
        poolclass=pool.NullPool,
    )

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

        with context.begin_transaction():
            context.run_migrations() 
開發者ID:lttkgp,項目名稱:C-3PO,代碼行數:21,代碼來源:env.py

示例11: __init__

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import engine_from_config [as 別名]
def __init__(self, config=None, master_url=None, slaves_url=None, session_conf=None, **kwargs):

        """
        連接對象init
        :param base_conf: 全局配置,sqlalchemy.開頭
        :param master_url: 主庫連接
        :param slaves_url: 從庫連接
        :param others_url: 其他類型,暫未實現
        :param kwargs: 自定義配置
        """
        super(SQLAlchemy, self).__init__(config=config, master_url=master_url, slaves_url=slaves_url,
                                         session_conf=session_conf, **kwargs)
        # 每一個engine都會有一個factory,感覺挺鬧心,要是有10個engine。。就得10個factory,未來尋找一下全局隻有一個factory的方案
        self._slave_tmp = None
        session_conf['query_cls'] = BaseQuery
        self._master_engine = engine_from_config(self.config, prefix=_SQLALCHEMY_PREFIX, url=master_url[0], **kwargs)
        self._master_session = create_session(self._master_engine, **session_conf)
        self._slaves_session = []
        self._slave_engine = []

        for slave in slaves_url:
            slave_engine = engine_from_config(self.config, prefix=_SQLALCHEMY_PREFIX, url=slave, **kwargs)
            self._slave_engine.append(slave_engine)
            self._slaves_session.append(create_session(slave_engine, **session_conf)) 
開發者ID:mqingyn,項目名稱:torngas,代碼行數:26,代碼來源:dbalchemy.py

示例12: run_migrations_online

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import engine_from_config [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.

    """
    connectable = engine_from_config(
        config.get_section(config.config_ini_section),
        prefix='sqlalchemy.',
        poolclass=pool.NullPool,
    )

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

        with context.begin_transaction():
            context.run_migrations() 
開發者ID:item4,項目名稱:yui,代碼行數:22,代碼來源:env.py

示例13: run_migrations_online

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import engine_from_config [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.

    """
    connectable = getattr(config, 'connection', None)

    if connectable is None:
        connectable = engine_from_config(
            config.get_section(config.config_ini_section),
            prefix='sqlalchemy.',
            poolclass=pool.NullPool)

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

        with context.begin_transaction():
            context.run_migrations() 
開發者ID:a10networks,項目名稱:a10-neutron-lbaas,代碼行數:26,代碼來源:env.py

示例14: run_migrations_online

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import engine_from_config [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 = engine_from_config(
                config.get_section(config.config_ini_section),
                prefix='sqlalchemy.',
                poolclass=pool.NullPool)

    connection = engine.connect()
    context.configure(connection=connection,
                      target_metadata=target_metadata,
                      transaction_per_migration=True)

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


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