simple update in sqlalchemy

后端 未结 1 1859
生来不讨喜
生来不讨喜 2021-01-02 14:46

UserTable is:

  • id (INT)

  • name (STR)

  • last_login (DATETIME)

Serving a web page request i have a user

相关标签:
1条回答
  • 2021-01-02 14:59

    Assuming you have a mapper UserTable in place:

    DBSession.query(UserTable).filter_by(id = user_id).\
        update({"last_login":datetime.datetime.now()}, synchronize_session=False)
    

    Additional parameters in the docs.

    0 讨论(0)
提交回复
热议问题