flask SQLAlchemy相关错误收集
1、解决 SQLAlchemy 提示 Instance is not bound to a Session 错误的问题
原因是前面调用函数中已经 db.session.commit() 了,session 已经被提交,导致操作的 model 对象已经不在当前 session 中了。 解决的办法就是:把对象重新加入到当前 session 中:
解决办法:
db.session.refresh()
1、解决 SQLAlchemy 提示 Instance is not bound to a Session 错误的问题
原因是前面调用函数中已经 db.session.commit() 了,session 已经被提交,导致操作的 model 对象已经不在当前 session 中了。 解决的办法就是:把对象重新加入到当前 session 中:
解决办法:
db.session.refresh()