Created
July 11, 2013 15:04
-
-
Save robcowie/5976242 to your computer and use it in GitHub Desktop.
Get changed columns from a sqlalchemy mapped object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy.inspection import inspect | |
def changed_columns(obj): | |
info = inspect(obj) | |
return dict((name, attr.history) for name, attr | |
in info.attrs.items() if attr.history.has_changes()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment