Search code examples
pythonmysqlsqlalchemyalembic

Inserting column to all tables in my database


I am required to create an evolution in alembic which adds two new columns to all tables in the database (excluding of course the alembic tables). Is it possible in alembic to iterate over all tables and execute alembic commands on them?


Solution

  • Sqlalchemy seems to support that, see here: SQL Alchemy - Getting a list of tables

    Other than that, you can always use a DB-specific query to get a list of tables and then execute queries on them.