Hello,

I want to increment a column by 1 with

UPDATE table SET column = column + 1 WHERE id = %(id)s,

however, when writing "instance.column += 1" in python, it translates it to

UPDATE table SET column = <OLD_VALUE> + 1, therefore, because while 
using many concurrent transactions, using <OLD_VALUE> is not correct, I 
changed the simple line in python to smth huge like this:

update_statement = table.update(table.c.id == instance.id, {'column': 
text('column + 1')})
meta.Session.execute(update_statement)

Is there a way to make it simpler?

Regards, Igor Katson.

--

You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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.


Reply via email to