feat: 数据库合并优化与拼音查询

This commit is contained in:
Zheng Huang 2024-05-22 12:00:43 +08:00
parent 0ff56fe695
commit 45bc146f9c
2 changed files with 11 additions and 3 deletions

View File

@ -72,7 +72,7 @@ class ParsingMicroMsg(DatabaseBase):
def user_list(self, word=None): def user_list(self, word=None):
""" """
获取联系人列表 获取联系人列表
:param MicroMsg_db_path: MicroMsg.db 文件路径 :param word 查询关键字可以是用户名昵称备注描述允许拼音
:return: 联系人列表 :return: 联系人列表
""" """
users = [] users = []
@ -87,6 +87,8 @@ class ParsingMicroMsg(DatabaseBase):
f"OR A.NickName LIKE '%{word}%' " f"OR A.NickName LIKE '%{word}%' "
f"OR A.Remark LIKE '%{word}%' " f"OR A.Remark LIKE '%{word}%' "
f"OR A.Alias LIKE '%{word}%' " f"OR A.Alias LIKE '%{word}%' "
f"OR A.QuanPin LIKE LOWER('%{word}%') "
f"OR LOWER(A.PYInitial) LIKE LOWER('%{word}%') "
# f"OR A.Reserved6 LIKE '%{word}%' " # f"OR A.Reserved6 LIKE '%{word}%' "
"ORDER BY A.NickName DESC;") "ORDER BY A.NickName DESC;")
result = self.execute_sql(sql) result = self.execute_sql(sql)

View File

@ -299,7 +299,7 @@ def merge_db(db_paths, save_path="merge.db", CreateTime: int = 0, endCreateTime:
return save_path return save_path
def decrypt_merge(wx_path, key, outpath="", CreateTime: int = 0, endCreateTime: int = 0) -> (bool, str): def decrypt_merge(wx_path, key, outpath="", db_type: list[str] = [], CreateTime: int = 0, endCreateTime: int = 0) -> (bool, str):
""" """
解密合并数据库 msg.db, microMsg.db, media.db,注意会删除原数据库 解密合并数据库 msg.db, microMsg.db, media.db,注意会删除原数据库
:param wx_path: 微信路径 eg: C:\*******\WeChat Files\wxid_********* :param wx_path: 微信路径 eg: C:\*******\WeChat Files\wxid_*********
@ -319,7 +319,13 @@ def decrypt_merge(wx_path, key, outpath="", CreateTime: int = 0, endCreateTime:
# 分割wx_path的文件名和父目录 # 分割wx_path的文件名和父目录
msg_dir = os.path.dirname(wx_path) msg_dir = os.path.dirname(wx_path)
my_wxid = os.path.basename(wx_path) my_wxid = os.path.basename(wx_path)
db_type = ["MSG", "MediaMSG", "MicroMsg", "OpenIMContact", "OpenIMMedia", "OpenIMMsg", "Favorite"] db_type_set: set[str] = {"MSG", "MediaMSG", "MicroMsg", "OpenIMContact", "OpenIMMedia", "OpenIMMsg", "Favorite"}
if len(db_type) == 0:
db_type = list(db_type_set)
else:
for i in db_type:
if i not in db_type_set:
return False, f"db_type参数错误, 可用选项 {db_type_set}"
# 解密 # 解密
code, wxdbpaths = get_core_db(wx_path, db_type) code, wxdbpaths = get_core_db(wx_path, db_type)
if not code: if not code: