Skip to content Skip to sidebar Skip to footer

SQLAlchemy Inheritance Not Working

I'm using Flask and SQLAlchemy. I have used my own abstract base class and inheritance. When I try to use my models in the python shell I get the following error: >>> from

Solution 1:

Try adding

 __table_args__ = {'extend_existing': True} 

to your User class right under __tablename__=

cheers


Solution 2:

Another option, if you don't already have data in your pre-existing database, is to drop it, recreate it without the tables. Then interactively run your "models.py" script (you would need to add a little code at the bottom to allow this), then in the interactive Python console do "db.create_all()" and it should create the tables based on your classes.


Post a Comment for "SQLAlchemy Inheritance Not Working"