Skip to content

How can I access the "current" revision after the migration has run *inside* the env.py script? #1667

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

You must be logged in to vote

So I tried to run alembic current in a subprocess and capture the output. This hangs. I suspect that the transaction is still active and a lock is preventing the script to finish (rough guess).

that would not be the issue there unless you have other connections opened, the transaction scope is entirely under your control in the env.py file in your project.

alembic current works with what you are calling a "side effect" because alembic relies exclusively on the env.py file and it's transaction block to gain connectivity. however, if you have a connection already and want to use that to get "current" for the database referenced by that connection, you can use the API directly and you can …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@exhuma
Comment options

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