From e0b70ddc3979f27555c514db45ded67f7c9d7f6a Mon Sep 17 00:00:00 2001 From: xaoyaoo Date: Fri, 15 Mar 2024 15:45:59 +0800 Subject: [PATCH] fix --- pywxdump/analyzer/export_chat.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pywxdump/analyzer/export_chat.py b/pywxdump/analyzer/export_chat.py index 4124049..36967e1 100644 --- a/pywxdump/analyzer/export_chat.py +++ b/pywxdump/analyzer/export_chat.py @@ -306,6 +306,7 @@ def get_chat_count(MSG_db_path: [str, list], username: str = ""): for row in result: username, chat_count = row chat_counts[username] = chat_count + db1.close() return chat_counts @@ -318,8 +319,12 @@ def get_all_chat_count(MSG_db_path: [str, list]): sql = f"SELECT COUNT(*) FROM MSG;" db1 = sqlite3.connect(MSG_db_path) result = execute_sql(db1, sql) - chat_counts = result[0][0] - return chat_counts + if result and len(result) > 0: + chat_counts = result[0][0] + db1.close() + return chat_counts + db1.close() + return 0 def export_csv(username, outpath, MSG_ALL_db_path, page_size=5000):