From 7933638fdf7c73020144860efa23703cd514c081 Mon Sep 17 00:00:00 2001 From: Roman Kapl Date: Mon, 6 Feb 2017 11:27:10 +0100 Subject: [PATCH] Fix sqlite3 exception on python >= 3.6 . Bedup crashes on startup with: cannot change into wal mode from within a transaction This commit fixes the error by temporarily disabling transactions. For similar error reports and more discussion see: https://github.com/yadayada/acd_cli/issues/509 --- bedup/__main__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bedup/__main__.py b/bedup/__main__.py index b894950..95dde09 100644 --- a/bedup/__main__.py +++ b/bedup/__main__.py @@ -85,11 +85,15 @@ def sql_setup(dbapi_con, con_record): # So that writers do not block readers # https://www.sqlite.org/wal.html + # WAL mode can not be set inside a trasaction, so disable transactions + old_isolation = dbapi_con.isolation_level + dbapi_con.isolation_level = None cur.execute('PRAGMA journal_mode = WAL') cur.execute('PRAGMA journal_mode') val = cur.fetchone() # SQLite 3.7 is required assert val == ('wal',), val + dbapi_con.isolation_level = old_isolation def get_session(args):