in 0.4 there is atomic update, e.g. update set a=expression

syntax is something like 
table.update( values=dict-of-name-expression ).execute( 
**bindings-if-any)
expressions is whatever sa sql expression 


On Tuesday 11 September 2007 09:25:46 Hermann Himmelbauer wrote:
> Hi,
> I need to safely increase a numeric value via SQLAlchemy:
> I have a table that has a column with numeric data. For increasing
> the value, I need to read the data, add some value and store it, so
> it would look like that:
>
> - select myvalue from mytable
> - myvalue += 123
> - update mytable and set myvalue to 123
>
> However, problems arise when two of this operations are done
> simultaneously, e.g. operation A and B:
>
> A - select
> B - select
> A - increase
> B - increase
> A - update
> B - update
>
> In this case, operation A is overwritten by B.
>
> One viable solution would be to make the operation atomic, by e.g.
> locking the database row. Is this possible with SQLAlchemy? If yes,
> how?
>
> Or is there a better way?
>
> Best Regards,
> Hermann



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to