From 67937d33e338efd7adf40e73f81ae1e4e3b9fb64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 18 Feb 2025 22:09:07 +0100 Subject: [PATCH] [archive] fix NameError when SQLite database path doesn't exist fixes regression introduced in 841bc9f6 --- gallery_dl/archive.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/gallery_dl/archive.py b/gallery_dl/archive.py index 72e0e16e..c7438cef 100644 --- a/gallery_dl/archive.py +++ b/gallery_dl/archive.py @@ -47,15 +47,13 @@ class DownloadArchive(): _sqlite3 = None def __init__(self, path, keygen, table=None, pragma=None, cache_key=None): - if self._sqlite3 is None: - import sqlite3 - DownloadArchive._sqlite3 = sqlite3 + DownloadArchive._sqlite3 = __import__("sqlite3") try: con = self._sqlite3.connect( path, timeout=60, check_same_thread=False) - except sqlite3.OperationalError: + except self._sqlite3.OperationalError: os.makedirs(os.path.dirname(path)) con = self._sqlite3.connect( path, timeout=60, check_same_thread=False) @@ -147,8 +145,7 @@ class DownloadArchivePostgresql(): def __init__(self, uri, keygen, table=None, pragma=None, cache_key=None): if self._psycopg is None: - import psycopg - DownloadArchivePostgresql._psycopg = psycopg + DownloadArchivePostgresql._psycopg = __import__("psycopg") self.connection = con = self._psycopg.connect(uri) self.cursor = cursor = con.cursor()