原本运行正常的web服务,在数据库模型中加了一行之后报错:
sqlalchemy.exc.OperationalError
sqlalchemy.exc.OperationalError: (OperationalError) no such column: comments.confirmed 'SELECT count(*) AS count_1 \nFROM (SELECT comments.id AS comments_id, comments.author_id AS comments_author_id, comments.post_id AS comments_post_id, comments.confirmed AS comments_confirmed \nFROM comments \nWHERE ? = comments.post_id) AS anon_1' (104,)
用的是python内置sqlite,代码如下:
class Comment(db.Model):
tablename = 'comments'
id = db.Column(db.Integer, primary_key=True)
body = db.Column(db.Text)
body_html = db.Column(db.Text)
timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)
disabled = db.Column(db.Boolean)
author_id = db.Column(db.Integer, db.ForeignKey('users.id'))
post_id = db.Column(db.Integer, db.ForeignKey('posts.id'))
confirmed = db.Column(db.Boolean, default=False) ##就只是加了这一行,添加后也更新过数据库模型
shell中能查到这一列:
(venv) F:\flask\flask1>python manage.py db upgrade
INFO [alembic.migration] Context impl SQLiteImpl.
INFO [alembic.migration] Will assume non-transactional DDL.
(venv) F:\flask\flask1>python manage.py shell
~~Comment.confirmed
sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x000000000436BB70>
求帮忙,自学中……(:哭