def make_transient_to_detached(instance):
    state = attributes.instance_state(instance)
    if state.session_id or state.key:
        raise sa_exc.InvalidRequestError(
            "Given object must be transient")
    state.key = state.mapper._identity_key_from_state(state)
    if state.deleted:
        del state.deleted
    state._commit_all(state.dict)
    state._expire_attributes(state.dict, state.unloaded)
Make the given transient instance 'detached'.
dataset/ETHPy150Open goFrendiAsgard/kokoropy/kokoropy/packages/sqlalchemy/orm/session.py/make_transient_to_detached