sqlalchemy.orm.exc.DetachedInstanceError: 错误解决

使用sqlchemy查询出一个集合的时候第一个对象可以使用,后面的就报如下错误。

sqlalchemy.orm.exc.DetachedInstanceError: Instance <LoginInfo at 0x6d79e70> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: http://sqlalche.me/e/bhk3)

网上搜到解决方案

Session=sessionmaker(bind=eng)
改为
Session=sessionmaker(bind=eng,expire_on_commit=False)


http://www.dangtrinh.com/2014/03/i-got-this-error-when-trying-to.html

  

posted @ 2018-03-27 09:54  公众号python学习开发  阅读(1941)  评论(0编辑  收藏  举报