Reputation: 147
When setting AutoCommit to false; does this mean that I have to commit after executing every SQL command in my application.
Here's a scenario
SQL1 doesn't need to be a transaction. SQL2 needs to be a transaction.
If I set AutoCommit to false, does that mean I have to alter all my code, and put "commit" after every SQL1 like commands ?
Upvotes: 2
Views: 35
Reputation: 180788
Set AutoCommit
to true
when you want to execute SQL statements individually. Every SQL statement will automatically be executed in its own individual transaction.
Set AutoCommit
to false
when you want to bundle multiple SQL statements into a single transaction and commit the transaction after all SQL statements have executed.
The way I read the documentation, a transaction is implicitly created when you execute your first SQL statement. It then commits immediately if AutoCommit
is set to true
, or continues accepting further SQL statements into the transaction until you manually commit, if AutoCommit
is set to false
.
Upvotes: 5