On 12/20/09 13:31 , Igor Katson wrote: > I want to increment a column by 1 with > > UPDATE table SET column = column + 1 WHERE id = %(id)s,
This is covered here: http://www.sqlalchemy.org/docs/06/sqlexpression.html > however, when writing "instance.column += 1" in python, it translates it to > > UPDATE table SET column = <OLD_VALUE> + 1 That's because instance.column returns the integer value. If you do "table.c.column + 1", however, that will return a _BinaryExpression. So, what you want, is something like table.update(where_clause, dict(column=table.c.column + 1) Hope this helps. -- Alex Brasetvik -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. 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.
