Python sqlalchemy.engine_from_config() Examples
The following are 30
code examples of sqlalchemy.engine_from_config().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sqlalchemy
, or try the search function
.
Example #1
Source File: env.py From hydrus with MIT License | 7 votes |
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()
Example #2
Source File: env.py From data-driven-web-apps-with-pyramid-and-sqlalchemy with MIT License | 6 votes |
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()
Example #3
Source File: env.py From maubot with GNU Affero General Public License v3.0 | 6 votes |
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()
Example #4
Source File: env.py From git-hammer with Apache License 2.0 | 6 votes |
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()
Example #5
Source File: env.py From backend.ai-manager with GNU Lesser General Public License v3.0 | 6 votes |
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()
Example #6
Source File: env.py From comport with BSD 3-Clause "New" or "Revised" License | 6 votes |
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()
Example #7
Source File: env.py From SempoBlockchain with GNU General Public License v3.0 | 6 votes |
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()
Example #8
Source File: env.py From cloud-inquisitor with Apache License 2.0 | 6 votes |
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()
Example #9
Source File: env.py From spkrepo with MIT License | 6 votes |
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()
Example #10
Source File: env.py From crestify with BSD 3-Clause "New" or "Revised" License | 6 votes |
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()
Example #11
Source File: env.py From C-3PO with MIT License | 6 votes |
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()
Example #12
Source File: dbalchemy.py From torngas with BSD 3-Clause "New" or "Revised" License | 6 votes |
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))
Example #13
Source File: env.py From yui with GNU Affero General Public License v3.0 | 6 votes |
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()
Example #14
Source File: env.py From a10-neutron-lbaas with Apache License 2.0 | 6 votes |
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()
Example #15
Source File: env.py From whiskyton with MIT License | 6 votes |
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()
Example #16
Source File: env.py From yui with GNU Affero General Public License v3.0 | 6 votes |
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()
Example #17
Source File: env.py From data-driven-web-apps-with-pyramid-and-sqlalchemy with MIT License | 6 votes |
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()
Example #18
Source File: env.py From data-driven-web-apps-with-pyramid-and-sqlalchemy with MIT License | 6 votes |
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()
Example #19
Source File: env.py From data-driven-web-apps-with-pyramid-and-sqlalchemy with MIT License | 6 votes |
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()
Example #20
Source File: env.py From data-driven-web-apps-with-pyramid-and-sqlalchemy with MIT License | 6 votes |
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()
Example #21
Source File: env.py From data-driven-web-apps-with-pyramid-and-sqlalchemy with MIT License | 6 votes |
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()
Example #22
Source File: env.py From data-driven-web-apps-with-pyramid-and-sqlalchemy with MIT License | 6 votes |
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()
Example #23
Source File: env.py From data-driven-web-apps-with-pyramid-and-sqlalchemy with MIT License | 6 votes |
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()
Example #24
Source File: env.py From data-driven-web-apps-with-pyramid-and-sqlalchemy with MIT License | 6 votes |
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()
Example #25
Source File: env.py From data-driven-web-apps-with-pyramid-and-sqlalchemy with MIT License | 6 votes |
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()
Example #26
Source File: env.py From data-driven-web-apps-with-pyramid-and-sqlalchemy with MIT License | 6 votes |
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()
Example #27
Source File: env.py From learning-python with MIT License | 6 votes |
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()
Example #28
Source File: initializedb.py From learning-python with MIT License | 6 votes |
def main(argv=sys.argv): if len(argv) < 2: usage(argv) config_uri = argv[1] options = parse_vars(argv[2:]) setup_logging(config_uri) settings = get_appsettings(config_uri, options=options) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.create_all(engine) with transaction.manager: #model = MyModel(name='one', value=1) #DBSession.add(model) admin = User() admin.name = 'admin' admin.password = 'admin' admin.email = 'admin@localhost' DBSession.add(admin)
Example #29
Source File: env.py From chainerui with MIT License | 6 votes |
def run_migrations_online(config): """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: alembic.context.configure(connection=connection) with alembic.context.begin_transaction(): alembic.context.run_migrations()
Example #30
Source File: env.py From openmoves with MIT License | 6 votes |
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()