sqlalchemy how to get an id of newly added object code example
Example 1: sqlalchemy return id after insert
session.flush()
print(f.id)
Example 2: sqlalchemy return id after insert
f = Foo(bar='x')
session.add(f)
session.flush()
print(f.id) # will return the obj id