sqlalchemy return id after insert
snippet in sql

sqlalchemy return id after insert

user2389

session.flush()  
print(f.id)

sqlalchemy return id after insert

user5052

f = Foo(bar='x')
session.add(f)
session.flush()

print(f.id) # will return the obj id