Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLAlchemy: Will session queries still work after a commit?

Tags:

sqlalchemy

I just started in this SQLAlchemy ORM and I was wondering, if after calling a commit to a session, if you can still use that 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()

Would all this code work?

like image 265
Wiz Avatar asked Jun 29 '12 01:06

Wiz


1 Answers

Short answer: Yes.
Long answer: Please read Using the Session and also the Managing Transactions part of it.

like image 174
van Avatar answered Nov 20 '22 14:11

van