From d0f129295f95da3728434bae7ea1257edcb93e80 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Wed, 8 Jun 2022 18:29:53 -0700 Subject: [PATCH] move sqlite3 checks up a level --- archivebox/config.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/archivebox/config.py b/archivebox/config.py index 28efcee9..6afd9c4a 100644 --- a/archivebox/config.py +++ b/archivebox/config.py @@ -1203,12 +1203,6 @@ def setup_django(out_dir: Path=None, check_db=False, config: ConfigDict=CONFIG, except django.db.utils.OperationalError: call_command("createcachetable", verbosity=0) - - with connection.cursor() as cursor: - config['SQLITE_VERSION'] = cursor.execute("SELECT sqlite_version();").fetchone()[0] - config['SQLITE_JOURNAL_MODE'] = cursor.execute('PRAGMA journal_mode;').fetchone()[0] - config['SQLITE_EXTENSIONS'] = ['JSON1'] if ('ENABLE_JSON1',) in cursor.execute('PRAGMA compile_options;').fetchall() else [] - # if archivebox gets imported multiple times, we have to close # the sqlite3 whenever we init from scratch to avoid multiple threads # sharing the same connection by accident @@ -1220,5 +1214,10 @@ def setup_django(out_dir: Path=None, check_db=False, config: ConfigDict=CONFIG, assert sql_index_path.exists(), ( f'No database file {SQL_INDEX_FILENAME} found in: {config["OUTPUT_DIR"]} (Are you in an ArchiveBox collection directory?)') + with connection.cursor() as cursor: + config['SQLITE_VERSION'] = cursor.execute("SELECT sqlite_version();").fetchone()[0] + config['SQLITE_JOURNAL_MODE'] = cursor.execute('PRAGMA journal_mode;').fetchone()[0] + config['SQLITE_EXTENSIONS'] = ['JSON1'] if ('ENABLE_JSON1',) in cursor.execute('PRAGMA compile_options;').fetchall() else [] + except KeyboardInterrupt: raise SystemExit(2)