Flask sqlalchemy.exc.OperationalError: (OperationalError) no such table when trying to update database with SQLAlchemy

后端 未结 3 637
心在旅途
心在旅途 2021-01-25 13:31

I\'m new to Flask, and having some issues setting up a very basic Flask app. Right now, I\'m trying to get the user to submit a form on the homepage and then save that form to

3条回答
  •  一整个雨季
    2021-01-25 14:14

    If you are using flask-migrate library, you should run commands below to create and apply migrations. Database and tables will be created.

    flask db migrate
    flask db upgrade
    

    Before running this commands you should create models. Models objects represent tables on a database. In your case, it may look like this

    class Contact(db.Model):
        id = db.Column(db.Integer, primary_key=True)
        username = db.Column(db.String(80), unique=True, nullable=False)
        email = db.Column(db.String(120), unique=True, nullable=False)
    

提交回复
热议问题