增加数据库查询失败的容错
This commit is contained in:
parent
183f04a1b9
commit
d4c2dcfaa0
@ -58,6 +58,8 @@ class ParsingMSG(DatabaseBase):
|
|||||||
sql = f"SELECT StrTalker, COUNT(*) FROM MSG GROUP BY StrTalker ORDER BY COUNT(*) DESC;"
|
sql = f"SELECT StrTalker, COUNT(*) FROM MSG GROUP BY StrTalker ORDER BY COUNT(*) DESC;"
|
||||||
|
|
||||||
result = self.execute_sql(sql)
|
result = self.execute_sql(sql)
|
||||||
|
if not result:
|
||||||
|
return {}
|
||||||
df = pd.DataFrame(result, columns=["wxid", "msg_count"])
|
df = pd.DataFrame(result, columns=["wxid", "msg_count"])
|
||||||
# # 排序
|
# # 排序
|
||||||
df = df.sort_values(by="msg_count", ascending=False)
|
df = df.sort_values(by="msg_count", ascending=False)
|
||||||
@ -257,7 +259,8 @@ class ParsingMSG(DatabaseBase):
|
|||||||
"SELECT localId, IsSender, StrContent, StrTalker, Sequence, Type, SubType,CreateTime,MsgSvrID,DisplayContent,CompressContent,BytesExtra,ROW_NUMBER() OVER (ORDER BY CreateTime ASC) AS id "
|
"SELECT localId, IsSender, StrContent, StrTalker, Sequence, Type, SubType,CreateTime,MsgSvrID,DisplayContent,CompressContent,BytesExtra,ROW_NUMBER() OVER (ORDER BY CreateTime ASC) AS id "
|
||||||
"FROM MSG ORDER BY CreateTime ASC LIMIT ?,?")
|
"FROM MSG ORDER BY CreateTime ASC LIMIT ?,?")
|
||||||
result1 = self.execute_sql(sql, (start_index, page_size))
|
result1 = self.execute_sql(sql, (start_index, page_size))
|
||||||
|
if not result1:
|
||||||
|
return [], []
|
||||||
data = []
|
data = []
|
||||||
wxid_list = []
|
wxid_list = []
|
||||||
for row in result1:
|
for row in result1:
|
||||||
|
@ -17,6 +17,8 @@ class ParsingMediaMSG(DatabaseBase):
|
|||||||
def get_audio(self, MsgSvrID, is_play=False, is_wave=False, save_path=None, rate=24000):
|
def get_audio(self, MsgSvrID, is_play=False, is_wave=False, save_path=None, rate=24000):
|
||||||
sql = "select Buf from Media where Reserved0=? "
|
sql = "select Buf from Media where Reserved0=? "
|
||||||
DBdata = self.execute_sql(sql, (MsgSvrID,))
|
DBdata = self.execute_sql(sql, (MsgSvrID,))
|
||||||
|
if not DBdata:
|
||||||
|
return False
|
||||||
if len(DBdata) == 0:
|
if len(DBdata) == 0:
|
||||||
return False
|
return False
|
||||||
data = DBdata[0][0] # [1:] + b'\xFF\xFF'
|
data = DBdata[0][0] # [1:] + b'\xFF\xFF'
|
||||||
|
@ -88,6 +88,8 @@ class ParsingMicroMsg(DatabaseBase):
|
|||||||
# 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)
|
||||||
|
if not result:
|
||||||
|
return []
|
||||||
for row in result:
|
for row in result:
|
||||||
# 获取wxid,昵称,备注,描述,头像
|
# 获取wxid,昵称,备注,描述,头像
|
||||||
username, nickname, remark, Alias, describe, headImgUrl = row
|
username, nickname, remark, Alias, describe, headImgUrl = row
|
||||||
@ -107,6 +109,8 @@ class ParsingMicroMsg(DatabaseBase):
|
|||||||
"FROM ChatInfo C "
|
"FROM ChatInfo C "
|
||||||
"ORDER BY C.LastReadedCreateTime DESC;")
|
"ORDER BY C.LastReadedCreateTime DESC;")
|
||||||
result = self.execute_sql(sql)
|
result = self.execute_sql(sql)
|
||||||
|
if not result:
|
||||||
|
return []
|
||||||
for row in result:
|
for row in result:
|
||||||
# 获取用户名、昵称、备注和聊天记录数量
|
# 获取用户名、昵称、备注和聊天记录数量
|
||||||
username, LastReadedCreateTime, LastReadedSvrId = row
|
username, LastReadedCreateTime, LastReadedSvrId = row
|
||||||
@ -133,6 +137,8 @@ class ParsingMicroMsg(DatabaseBase):
|
|||||||
f"where A.ChatRoomName LIKE '%{roomwxid}%' "
|
f"where A.ChatRoomName LIKE '%{roomwxid}%' "
|
||||||
"ORDER BY A.ChatRoomName ASC;")
|
"ORDER BY A.ChatRoomName ASC;")
|
||||||
result = self.execute_sql(sql)
|
result = self.execute_sql(sql)
|
||||||
|
if not result:
|
||||||
|
return []
|
||||||
room_datas = []
|
room_datas = []
|
||||||
for row in result:
|
for row in result:
|
||||||
# 获取用户名、昵称、备注和聊天记录数量
|
# 获取用户名、昵称、备注和聊天记录数量
|
||||||
|
Loading…
Reference in New Issue
Block a user