Skip to content

Instantly share code, notes, and snippets.

@robcowie
Created July 11, 2013 15:04
Show Gist options
  • Save robcowie/5976242 to your computer and use it in GitHub Desktop.
Save robcowie/5976242 to your computer and use it in GitHub Desktop.
Get changed columns from a sqlalchemy mapped object
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