Sqlalchemy session.refresh does not refresh object

后端 未结 4 756
[愿得一人]
[愿得一人] 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:09

    Merge the session.

    u = session.query(User).get(id)
    u.name = 'user1_changed'
    u = session.merge(u)
    

    This will update the database and return the newer object.

提交回复
热议问题