the API to retrieve history for an individual attribute looks like:

from sqlalchemy.orm import attributes
a, u, d = attributes.get_history(Class.attribute, obj)

where a, u, d are lists of added items, unchanged items, and deleted
items, respectively.   For a scalar attributes, a, u, d are lists of
length one.

Example:


user = Session.query(User).get(1)
a, u, d = attributes.get_history(User.name, user)

a, u, d would be along the lines of:

['jack'], [], ['ed']

to indicate the name field was changed from 'ed' to 'jack'.


Adam wrote:
>
> I have a project where I need to monitor the changes to a record -
> when using after_update, is it possible to see what the data was
> before the update?
> >
>


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