In sqlite python, one has to run commit() to make sure a SQL statement is executed if auto-commit is not enabled. Auto-commit is enabled by doing something like this sqlite3.connect('sqlitedb.db', isolation_level=None)
Is it a good practice to enable auto-commit all the time? THis is to avoid bugs that can happen when one forgets to run commit().
What are some situations, if any, that auto-commit is better to be disabled?
I am using sqlite3 and python v3.6
Autocommit should be disabled if multiple operations belong together logically to ensure that not only some of them are executed (atomicity).
Additionally it should be disabled if multiple operations are done consecutively in a short period of time for performance reasons.
For databases with concurrent access from different threads/processes additional consistency considerations apply but this usage is unlikely for Sqlite.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With