SQLAlchemy - select for update example

前端 未结 3 1975
太阳男子
太阳男子 2020-12-05 13:01

I\'m looking for a complete example of using select for update in SQLAlchemy, but haven\'t found one googling. I need to lock a single row and update a column, the followin

3条回答
  •  一向
    一向 (楼主)
    2020-12-05 13:40

    Yes, you do need to commit, which you can execute on the Engine or create a Transaction explicitely. Also the modifiers are specified in the values(...) method, and not execute:

    >>> conn.execute(users.update().
    ...              where(table.c.user=="test").
    ...              values(email="foo")
    ...              ) 
    >>> my_engine.commit()
    

提交回复
热议问题