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