After calling update(), I know that the return value has a .rowcount attribute that will reveal how many rows were changed. Is there a way to get the开发者_如何学运维 actual new values that they were changed to?
For example, if I do the SQLAlchemy equivalent of:
UPDATE t SET x=x+1 WHERE y=z
...is there a way to get the new value for x? Or do I have to do a SELECT?
The ResultProxy
has two methods, last_updated_params()
which returns a dictionary of every bind parameter value sent with the statement execution, as well as a collection postfetch_cols()
, a list of columns for which an inline SQL expression was embedded in the UPDATE (for which you'd have to post-SELECT the values). These collections are only populated for single-statement executions, not "executemany" calls which pass multiple sets of parameters along.
精彩评论