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

  

原文地址:https://www.cnblogs.com/c-x-a/p/8655769.html