Skip to content

Programmatic upgrade using async db driver #991

Answered by zzzeek
alejoar asked this question in Usage Questions
Discussion options

You must be logged in to vote

Place this function in your env.py script:

def run_migrations_online():
    connectable = config.attributes.get('connection', None)

    if connectable is None:
        # only create Engine if we don't have a Connection
        # from the outside
        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()
    else:
        context.

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@zzzeek
Comment options

@zzzeek
Comment options

@alejoar
Comment options

@lawalAfeez820
Comment options

@RafRaf
Comment options

Answer selected by alejoar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants