Hey, I'm using sqlalchemy-0.4.8 with mysql-5.0 on innodb tables. I'm having trouble updating 1 field in 1 row concurrently. The problem is that I can't seem to reliably update the fields. Simple example:
Program 1: .. session.close() session.begin() u = User.get(id=1).with_lockmode("update").first() print(u.bytes) u.bytes += 100 time.sleep(5) session.commit() Program 2: .. session.close() session.begin() u = User.get(id=1).with_lockmode("update").first() print(u.bytes) u.bytes -= 10 session.commit() print(u.trafficbytes) I start by running program 1 until it enters the sleep. It's holding the update lock on the user table. Now, I run program 2. It nicely waits until program 1 commits the session. However, u.bytes still has the value _before_ program 1 adds 100 to it. I expected it to get the newly, updated value. What am I doing wrong here? Is it because program 2 gets the database state it was in at the moment it starts the database transaction with session.begin() (while program 1 hasn't committed its update yet)? If so, how do I rewrite the code to get it to do what I mean? Kind regards, Bram --~--~---------~--~----~------------~-------~--~----~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---