From 0813ba25dbf7e287fe16e8385da7b8181455eabb Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Fri, 3 Mar 2017 19:52:41 +0000 Subject: [PATCH] Use transactions when writing metadata --- gramps/plugins/db/dbapi/dbapi.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gramps/plugins/db/dbapi/dbapi.py b/gramps/plugins/db/dbapi/dbapi.py index c677885da..06cdb60f5 100644 --- a/gramps/plugins/db/dbapi/dbapi.py +++ b/gramps/plugins/db/dbapi/dbapi.py @@ -378,6 +378,7 @@ class DBAPI(DbGeneric): key: string value: item, will be serialized here """ + self._txn_begin() self.dbapi.execute("SELECT 1 FROM metadata WHERE setting = ?", [key]) row = self.dbapi.fetchone() if row: @@ -388,6 +389,7 @@ class DBAPI(DbGeneric): self.dbapi.execute( "INSERT INTO metadata (setting, value) VALUES (?, ?)", [key, pickle.dumps(value)]) + self._txn_commit() def get_name_group_keys(self): """ @@ -871,6 +873,7 @@ class DBAPI(DbGeneric): return gstats def save_gender_stats(self, gstats): + self._txn_begin() self.dbapi.execute("DELETE FROM gender_stats") for key in gstats.stats: female, male, unknown = gstats.stats[key] @@ -878,6 +881,7 @@ class DBAPI(DbGeneric): "(given_name, female, male, unknown) " "VALUES (?, ?, ?, ?)", [key, female, male, unknown]) + self._txn_commit() def get_surname_list(self): """