문제

I need ID of an object which I've just added using session.add(). I need the auto-increment ID of this object before committing session.

If I called the object instance.id, I get None.

Is there a way to get ID of a object without committing?

도움이 되었습니까?

해결책

Simple answer: call session.flush().

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top