penguian / Boolean-Cayley-graphs

Investigations of Boolean functions, their Cayley graphs, and associated structures.
GNU General Public License v3.0
6 stars 1 forks source link

Fix sqlite3 transactions for classification databases #46

Closed penguian closed 1 year ago

penguian commented 2 years ago

Sqlite3 can sometimes commit changes to a database before a call to conn.commit(). See https://stackoverflow.com/questions/4699605/why-doesn-t-sqlite3-require-a-commit-call-to-save-data https://bugs.python.org/issue10740 sqlite3 module breaks transactions and potentially corrupts data (fixed in Python 3.6) https://bugs.python.org/issue39457 Add an autocommit property to sqlite3.Connection with a PEP 249 compliant manual commit mode and migrate (open) https://docs.python.org/3/library/sqlite3.html " The sqlite3 module does not adhere to the transaction handling recommended by PEP 249. Changed in version 3.6: sqlite3 used to implicitly commit an open transaction before DDL statements. This is no longer the case" See also https://www.sqlite.org/lang_transaction.html

The result of this behaviour is that if a process that calls classification_database_sqlite3.insert_classification() is interrupted, it could sometimes result in a corrupted database containing an incomplete classification.

Add manual transaction handling to classification_database_sqlite3, especially in insert_classification().