From 86deccd8e643f7f7ddf60ecd8311e71ecb0d4e09 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Mon, 27 Feb 2023 11:07:52 -0500 Subject: fix: Use "journal_mode=memory" if "journal_mode=off" fails. --- coverage/sqldata.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/coverage/sqldata.py b/coverage/sqldata.py index 42cf4501..3e47b4d8 100644 --- a/coverage/sqldata.py +++ b/coverage/sqldata.py @@ -1133,6 +1133,11 @@ class SqliteDb(AutoReprMixin): # PyPy needs the .close() calls here, or sqlite gets twisted up: # https://bitbucket.org/pypy/pypy/issues/2872/default-isolation-mode-is-different-on self.execute_void("pragma journal_mode=off") + if self.execute_one("pragma journal_mode") != "off": + # Some instances of Sqlite refuse to disable journal mode. + # Switching to memory mode prevents journal files from being written, + # even though we lose performance with unecessary rollback protection. + self.execute_void("pragma journal_mode=memory") # This pragma makes writing faster. self.execute_void("pragma synchronous=off") -- cgit v1.2.1