How to execute db.session.flush automatically by flask

after specifying the db.session.add, it is not actually sent to the database for execution. If you need to get the inserted id during session, you need to execute db.session.flush manually

is there any way to turn off this "feature" without manually performing any action that is automatically sent directly to the database server


you can check out the config.py in my project: https://github.com/eastossifrage/pyblog/blob/master/config.py

.
SQLALCHEMY_COMMIT_ON_TEARDOWN = True

this is what you want.

Menu