flask SQLAlchemy相关错误收集

1、解决 SQLAlchemy 提示 Instance is not bound to a Session 错误的问题

原因是前面调用函数中已经 db.session.commit() 了,session 已经被提交,导致操作的 model 对象已经不在当前 session 中了。 解决的办法就是:把对象重新加入到当前 session 中:

解决办法:

db.session.refresh()

 

posted @ 2019-02-12 17:20  万里沙来手一挥  阅读(625)  评论(0)    收藏  举报