From ea8d15ff8c5d8de4b6248a985756c3b50262c0c0 Mon Sep 17 00:00:00 2001 From: xaoyaoo Date: Fri, 22 Mar 2024 18:01:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E6=94=B9=E4=B8=BA=E5=85=B1=E7=94=A8=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=EF=BC=8C=E9=99=8D=E4=BD=8E=E6=97=B6=E9=97=B4=E5=BC=80?= =?UTF-8?q?=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pywxdump/analyzer/utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pywxdump/analyzer/utils.py b/pywxdump/analyzer/utils.py index b5e6693..2f8a779 100644 --- a/pywxdump/analyzer/utils.py +++ b/pywxdump/analyzer/utils.py @@ -190,6 +190,7 @@ class DBPool: cls.__db_pool[db_path] = sqlite3.connect(db_path, check_same_thread=False) cls.connection = cls.__db_pool[db_path] + def __init__(self, db_path): if db_path == "DBPOOL_INIT": return @@ -197,6 +198,10 @@ class DBPool: if db_path not in self.__db_pool: self.create_connection(db_path) self.connection = self.__db_pool.get(db_path) + # 检查数据库是否关闭 + if not self.connection: + self.create_connection(db_path) + self.connection = self.__db_pool.get(db_path) def __enter__(self): return self.connection