What's the difference between flush() and commit()?
- flush
: The session object registers transaction operations with session.add(), but doesn't yet communicate them to the database until session.flush() is called.
session.flush() communicates a series of operations to the database (insert, update, delete). The database maintains them as pending operations in a transaction. The changes aren't persisted permanently to disk, or visible to other transactions until the database receives a COMMIT for the current transaction (which is what session.commit() does).
- commit
: session.commit() commits (persists) those changes to the database.
more ...
https://stackoverflow.com/questions/4201455/sqlalchemy-whats-the-difference-between-flush-and-commit
반응형
'SW ENGINEERING > SqlAlchemy' 카테고리의 다른 글
[SQLAlchemy] update (0) | 2022.03.08 |
---|---|
[SQLAlchemy] subquery (0) | 2022.03.08 |
최근댓글