On Aug 2, 12:23 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > if you use a SessionTransaction (which is being simplified in the > next release), and then load your User with_lockmode as such: > > user = session.query(User).with_lockmode('update').load(<userid>) > > that will in all cases, whether <userid> was already loaded or not, > issue a SELECT...FOR UPDATE on the row containing that user id, and > it will overwrite all attributes on your User object with the values > retrieved from the database. so now, the "balance" attribute on > 'user' should be the latest value, and the row should be locked > against further changes. > > then, modify the "balance" attribute on your User object, modify > other attributes as needed, and flush(). after that, commit the > transaction.
Thanks, I'll try that. Is there a way I can do this without locking, though, such as by adding my own UPDATE query to the transaction? -Nick Johnson --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---