Sqlalchemy session.refresh does not refresh object

后端 未结 4 759
[愿得一人]
[愿得一人] 2021-02-05 17:27

I have the following mapping (straight from SA examples):

class User(Base):
    __tablename__ = \'users\'

    id = Column(Integer, primary_key=True)
    name =          


        
4条回答
  •  北荒
    北荒 (楼主)
    2021-02-05 18:19

    Did you try with "expire" as described in the official doc:

    http://docs.sqlalchemy.org/en/rel_0_8/orm/session.html#refreshing-expiring

    # expire objects obj1, obj2, attributes will be reloaded
    # on the next access:
    session.expire(user_1)
    session.refresh(user_1)
    

    Using expire on a object results in a reload that will occur upon next access.

提交回复
热议问题