pythonterminalsqlalchemy

add column to SQLAlchemy Table


I made a table using SQLAlchemy and forgot to add a column. I basically want to do this:

users.addColumn('user_id', ForeignKey('users.user_id'))

What's the syntax for this? I couldn't find it in the docs.


Solution

  • This is referred to as database migration (SQLAlchemy doesn't support migration out of the box). You can look at using sqlalchemy-migrate to help in these kinds of situations, or you can just ALTER TABLE through your chosen database's command line utility,