'Updates the state of the snapshot in the session.
Finds the SQLA object in the session if it exists or creates a new
object and updates the object with the column values stored in this
snapshot.'

def persist_state_to_session(self, session):

    db_obj = session.query(self._model_class).get(self._identity_key)
    if db_obj:
        for col in self._cols:
            setattr(db_obj, col, getattr(self, col))
    else:
        session.add(self._model_class(**{col: getattr(self, col) for col in self._cols}))
