SQLAlchemy gets added object id without session commit

I need the id of the object I just added using session.add(). I need the auto-increment identifier of this object before the session committing.

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

Is there a way to get the identifier of an object without committing?

+4
source share
1 answer

The simple answer is: a challenge session.flush().

+5
source

Source: https://habr.com/ru/post/1536538/


All Articles