[Flask] How to drop one table using Flask and SQLAlchemy
Jim Icenhower
jicenhower at yahoo.com
Sun Sep 6 23:07:45 CEST 2015
Hi,I'm using Flask appbuilder with SQLAlchemy. I would like to be able to drop one table instead of using drop_all(). I've attempted to use a bind to the table but I obviously don't understand what I'm doing. I've done this:
In models.py:
class CarClass(Model): CarClassID = Column(Integer, primary_key=True) EventID = Column(Integer, ForeignKey('event.EventID'), nullable=False) EventKey = Column(String(30), nullable=False) CarClassKey = Column(String(30), nullable=False) Description = Column(Text(1000), unique=True, nullable=False) Abbreviation = Column(String(10), unique=True, nullable=False) Event = relationship('Event') __bind_key__ = 'carclass'
In views.py:db.drop_all(bind=['carclass'])
This returns the error:AssertionError: Bind 'carclass' is not specified. Set it in the SQLALCHEMY_BINDS configuration variable.
Maybe I should not use binds. I just want to drop a table that is described by a class in models.py. Is there a better way than binds to drop one table?
Thanks!
Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20150906/2b27ace1/attachment.html>
More information about the Flask
mailing list