Skip to main content

SQLAlchemy

Migrations

Use the Operations.execute method.

First, create a migration:

alembic revision -m "electrify items"

Then execute the SQL in the upgrade function:

# ... docstring and revision identifiers ...

from alembic import op
import sqlalchemy as sa

def upgrade():
op.execute('ALTER TABLE items ENABLE ELECTRIC')

Event sourcing

One way of consuming a change feed from Postgres in Python is to use the psycopg2.extras.LogicalReplicationConnection.

See Integrations -> Event sourcing for more information.