Who said these two things have the same function?
In SQLAlchemy, a Session (can be regarded as) is a transaction. Each operation (basically) corresponds to one or more SQL statements. These SQL statements need to be sent to the database server to be actually executed, and the entire transaction needs to be committed to really take effect. , if not submitted, once your program hangs, all uncommitted transactions will be rolled back to the state before the transaction started.
Flush is to send the SQL statements that the client has not sent to the database server, and commit is to tell the database server to commit the transaction.
Simply put, you can see the effect in this Session after flushing, and you can see the effect in other Sessions after committing.
The functions are different.
Simply put:
Flush pre-commit is equal to being submitted to the database memory and has not yet been written to the database file;
Commit means writing the contents in the memory directly, and you can provide queries;
Who said these two things have the same function?
In SQLAlchemy, a Session (can be regarded as) is a transaction. Each operation (basically) corresponds to one or more SQL statements. These SQL statements need to be sent to the database server to be actually executed, and the entire transaction needs to be committed to really take effect. , if not submitted, once your program hangs, all uncommitted transactions will be rolled back to the state before the transaction started.
Flush is to send the SQL statements that the client has not sent to the database server, and commit is to tell the database server to commit the transaction.
Simply put, you can see the effect in this Session after flushing, and you can see the effect in other Sessions after committing.
The functions are different.
Simply put:
Flush pre-commit is equal to being submitted to the database memory and has not yet been written to the database file;
Commit means writing the contents in the memory directly, and you can provide queries;