-
-
Save inklesspen/dc6c7c55ab44b2d6b3bf355c3e4b7c0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from alembic import op | |
import sqlalchemy as sa | |
def upgrade(): | |
t_files = sa.table('files', sa.column('id', sa.String(32)), sa.column('content', sa.Blob())) | |
# we have to use get_bind() because op.execute() doesn't have a return value | |
# but by using get_bind() we can no longer generate SQL scripts for the migration; we have to run it live | |
connection = op.get_bind() | |
my_id = '14c3e928ed9d4ecaa57226bc5b628132' | |
data = connection.execute(sa.select([t_files.c.content]).where(t_files.c.id == my_id)).scalar() | |
new_data = transform_data(data) | |
connection.execute(t_files.update().where(t_files.c.id == my_id).values(content=new_data)) | |
def downgrade(): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I need to update my Alchemy then, yes.
And after the instant commit, will there be a new transaction or instant commits from thereon?