سؤال

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