SQLAlchemy: will session requests be executed after a commit?

I just started in this SQLAlchemy ORM, and I was wondering if after calling commit to the session, if you can still use this sesison to query and maybe even commit another time.

So for example

session = Session()
session.add(Foo())
session.commit()
print session.query(Foo).first()
session.add(Bar())
session.commit()

Will all this code work?

+5
source share
1 answer

Short answer: Yes.
Long answer: read Session Usage as well as Transaction Management part of it.

+4
source

All Articles