python - Update value checking previous one - SQLObject -


in application deployed, using sqlobject, need update value only if previous value match value.

the equivalent sql be:

update jobs set status='150' id=1234 , status='100' 

i need because have many instances of daemon on different servers (not knowing each others) may want take jobs , update db mark job "taken".

i want prevent "double updates" 2 nodes setting same value.

it nice if can result number of affected rows. result of 0 permit "job taken between fetch , update"...

the actual part of code doing update looks like:

def __setattr__(self, name, value):     """override setattr log build status changes"""     [...]     sqlobject.sqlobject.__setattr__(self, name, value) 

sqlobject has few api layers. there no way execute conditional update if use high-level api (sqlobject-inhertied classes). where-clause available in sqlbuilder's update.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -