I want to duplicate a model instance (row) in SQLAlchemy using the orm. My first thought was to do this:
i = session.query(Model) session.expunge(i) old_id
def duplicate(self): arguments = dict() for name, column in self.__mapper__.columns.items(): if not (column.primary_key or column.unique): arguments[name] = getattr(self, name) return self.__class__(**arguments)