From 88e691ef63001d36112b8e09d93cb4c69be785cf Mon Sep 17 00:00:00 2001 From: xaoyaoo Date: Wed, 28 Feb 2024 22:23:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96=E6=80=BB?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=95=B0=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pywxdump/analyzer/__init__.py | 3 ++- pywxdump/analyzer/export_chat.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pywxdump/analyzer/__init__.py b/pywxdump/analyzer/__init__.py index 5353663..6fe6e09 100644 --- a/pywxdump/analyzer/__init__.py +++ b/pywxdump/analyzer/__init__.py @@ -7,5 +7,6 @@ # ------------------------------------------------------------------------------- from .db_parsing import read_img_dat, read_emoji, decompress_CompressContent, read_audio_buf, read_audio, \ parse_xml_string, read_BytesExtra -from .export_chat import export_csv, get_contact_list, get_chatroom_list, get_msg_list, get_chat_count, export_json +from .export_chat import export_csv, get_contact_list, get_chatroom_list, get_msg_list, get_chat_count, export_json, \ + get_all_chat_count from .utils import get_type_name, get_name_typeid diff --git a/pywxdump/analyzer/export_chat.py b/pywxdump/analyzer/export_chat.py index 2d2d9b0..c238f0a 100644 --- a/pywxdump/analyzer/export_chat.py +++ b/pywxdump/analyzer/export_chat.py @@ -290,6 +290,18 @@ def get_chat_count(MSG_db_path: [str, list], username: str = ""): chat_counts[username] = chat_count return chat_counts +def get_all_chat_count(MSG_db_path: [str, list]): + """ + 获取聊天记录总数量 + :param MSG_db_path: MSG.db 文件路径 + :return: 聊天记录数量 + """ + 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 + def export_csv(username, outpath, MSG_ALL_db_path, page_size=5000): if not os.path.exists(outpath):