Skip to content

Instantly share code, notes, and snippets.

@ThiefMaster
Created December 29, 2012 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThiefMaster/4409236 to your computer and use it in GitHub Desktop.
Save ThiefMaster/4409236 to your computer and use it in GitHub Desktop.
def from_sqlalchemy(self, obj)
from sqlalchemy.orm import class_mapper, ColumnProperty
columns = [prop.key for prop in class_mapper(obj.__class__).iterate_properties
if isinstance(prop, ColumnProperty)]
for column in columns:
if column in self:
self[column].data = getattr(obj, column)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment