diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 5aae1dd1..066ce8ff 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,17 +4,11 @@
-
-
+
+
-
-
-
-
-
-
-
+
@@ -111,7 +105,7 @@
-
+
@@ -119,20 +113,20 @@
-
+
-
+
-
+
-
+
@@ -144,16 +138,16 @@
-
+
-
+
-
+
@@ -161,11 +155,11 @@
-
+
-
+
@@ -174,7 +168,7 @@
-
+
@@ -186,7 +180,7 @@
-
+
@@ -195,7 +189,7 @@
-
+
@@ -203,20 +197,20 @@
-
+
-
+
-
+
-
+
@@ -224,14 +218,14 @@
-
+
-
+
-
+
@@ -241,9 +235,9 @@
+
-
@@ -259,13 +253,6 @@
1672848140146
-
- 1680630659802
-
-
-
- 1680630659802
-
1680670947385
@@ -602,7 +589,14 @@
1700064404522
-
+
+ 1700145601841
+
+
+
+ 1700145601841
+
+
@@ -638,7 +632,6 @@
-
@@ -663,7 +656,8 @@
-
+
+
diff --git a/app/DataBase/micro_msg.py b/app/DataBase/micro_msg.py
index f437fada..2abfa613 100644
--- a/app/DataBase/micro_msg.py
+++ b/app/DataBase/micro_msg.py
@@ -37,5 +37,11 @@ def get_contact():
return result
+def close():
+ global DB
+ if DB:
+ DB.close()
+
+
if __name__ == '__main__':
get_contact()
diff --git a/app/DataBase/msg.py b/app/DataBase/msg.py
index f08acfed..6aa9b6b1 100644
--- a/app/DataBase/msg.py
+++ b/app/DataBase/msg.py
@@ -1,24 +1,40 @@
import os.path
+import re
import sqlite3
-DB = None
-cursor = None
-msg_path = "./app/Database/Msg/MSG0.db"
+DB = []
+cursor = []
+msg_root_path = "./app/Database/Msg/"
# misc_path = './Msg/Misc.db'
-if os.path.exists(msg_path):
- DB = sqlite3.connect(msg_path, check_same_thread=False)
- # '''创建游标'''
- cursor = DB.cursor()
+if os.path.exists(msg_root_path):
+ for root, dirs, files in os.walk(msg_root_path):
+ for file in files:
+ if re.match('^MSG[0-9]+\.db$', file):
+ # print('ok', file)
+ msg_path = os.path.join(msg_root_path, file)
+ DB0 = sqlite3.connect(msg_path, check_same_thread=False)
+ # '''创建游标'''
+ cursor0 = DB0.cursor()
+ DB.append(DB0)
+ cursor.append(cursor0)
def init_database():
global DB
global cursor
if not DB:
- if os.path.exists(msg_path):
- DB = sqlite3.connect(msg_path, check_same_thread=False)
- # '''创建游标'''
- cursor = DB.cursor()
+ if os.path.exists(msg_root_path):
+ for root, dirs, files in os.walk(msg_root_path):
+ for file in files:
+ # print(file)
+ if re.match('^MSG[0-9]+\.db$', file):
+ print('ok', file)
+ msg_path = os.path.join(msg_root_path, file)
+ DB0 = sqlite3.connect(msg_path, check_same_thread=False)
+ # '''创建游标'''
+ cursor0 = DB0.cursor()
+ DB.append(DB0)
+ cursor.append(cursor0)
def get_messages(username_):
@@ -28,15 +44,25 @@ def get_messages(username_):
where StrTalker=?
order by CreateTime
'''
- cursor.execute(sql, [username_])
- result_ = cursor.fetchall()
- return result_
+ result = []
+ for cur in cursor:
+ cur.execute(sql, [username_])
+ result_ = cur.fetchall()
+ # print(len(result))
+ result += result_
+ result.sort(key=lambda x: x[5])
+ return result
+
+
+def close():
+ for db in DB:
+ db.close()
if __name__ == '__main__':
from pprint import pprint
- msg_path = './Msg/MSG3.db'
+ msg_root_path = './Msg/'
init_database()
username = 'wxid_0o18ef858vnu22'
diff --git a/app/ui_pc/mainview.py b/app/ui_pc/mainview.py
index 7fc8ac4c..0b051e71 100644
--- a/app/ui_pc/mainview.py
+++ b/app/ui_pc/mainview.py
@@ -13,6 +13,7 @@
from PyQt5.QtWidgets import *
from app import config
+from app.DataBase import msg
from app.Ui.Icon import Icon
from . import mainwindow
from .contact import ContactWindow
@@ -112,3 +113,9 @@ def about(self):
f"QQ交流群:{config.contact}\n"
"地址:https://github.com/LC044/WeChatMsg"
)
+
+ def close(self) -> bool:
+ del self.listWidget
+ del self.stackedWidget
+ msg.close()
+ self.contact_window.close()