Why does the ROLLBACK information appear in the print log when using sqlalchemy to make only query queries (no data changes)?

[printed information]

after testing the ROLLBACK, execute
clipboard.png


clipboard.png

before self.db.close () in the code

session configuration code uses the default: autoflush=True, autocommit=False, expire_on_commit=True

[Information queried by yourself]

1. When sqlalchemy performs the query operation, it will first execute flush () to submit the information to the database (but no commit)

2. Add self.db.commit () after the query and the ROLLBACK information will not be printed

No relevant explanation was found on the web page

so I would like to ask, during the query operation, there is no change in the data, what is the operating mechanism? Why the ROLLBACK information will appear, the query must also be commit ()?

May.10,2022

1. Every time a session is opened, a transaction
2.close a session will be opened. If the transaction has not been committed, the
3.commit () will be rolled back. After the transaction has been committed, the transaction will not be rolled back

when close.
Menu