SQLAlchemy - select for update example
Posted
by
Mark
on Stack Overflow
See other posts from Stack Overflow
or by Mark
Published on 2012-04-09T23:23:36Z
Indexed on
2012/04/09
23:30 UTC
Read the original article
Hit count: 298
python
|sqlalchemy
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 following code doesn't work (blocks forever):
s = table.select(table.c.user=="test",for_update=True)
u = table.update().where(table.c.user=="test")
u.execute(email="foo")
Do I need a commit? How do I do that? As far as I know you need to: begin transaction select ... for update update commit
© Stack Overflow or respective owner