Use a mixin on the classes to create a dict of the column values. Then create a new object with that dict.
You can customize the mixin to include or exclude columns as you wish. I use this approach for revision tracking. Class Duplicable(object) @property def columns_as_dict(self): return = dict((col.name, getattr(self, col.name)) for col in sqlalchemy_orm.class_mapper(self.__class__).mapped_table.c) # ---- declare which columns to copy _columns_duplicable = [] @property def columns_as_dict(self): cols = dict((col.name, getattr(self, col.name)) for col in sqlalchemy_orm.class_mapper(self.__class__).mapped_table.c) return [c for c in cols if c in self._columns_duplicable] # ---- declare which columns to exclude _columns_notduplicable = [] @property def columns_as_dict(self): cols = dict((col.name, getattr(self, col.name)) for col in sqlalchemy_orm.class_mapper(self.__class__).mapped_table.c) return [c for c in cols if c not in self._columns_notduplicable] class MyClass(Base, Duplicable): _columns_duplicable = [ 'a', 'b', 'c', ] object_data = object.columns_as_dict -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.