增加获取总消息数的接口

This commit is contained in:
xaoyaoo 2024-02-28 22:23:04 +08:00
parent ad02472695
commit 88e691ef63
2 changed files with 14 additions and 1 deletions

View File

@ -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

View File

@ -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):