mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-23 03:22:17 +08:00
新增语音数据库查询模块
This commit is contained in:
parent
292533b1a2
commit
e281c08622
@ -7,8 +7,7 @@ import xml.etree.ElementTree as ET
|
|||||||
from app.log import log
|
from app.log import log
|
||||||
|
|
||||||
lock = threading.Lock()
|
lock = threading.Lock()
|
||||||
DB = None
|
|
||||||
cursor = None
|
|
||||||
db_path = "./app/Database/Msg/HardLinkImage.db"
|
db_path = "./app/Database/Msg/HardLinkImage.db"
|
||||||
root_path = 'FileStorage/MsgAttach/'
|
root_path = 'FileStorage/MsgAttach/'
|
||||||
|
|
||||||
|
58
app/DataBase/media_msg.py
Normal file
58
app/DataBase/media_msg.py
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import os.path
|
||||||
|
import sqlite3
|
||||||
|
import threading
|
||||||
|
|
||||||
|
lock = threading.Lock()
|
||||||
|
db_path = "./app/Database/Msg/MediaMSG3.db"
|
||||||
|
|
||||||
|
|
||||||
|
def singleton(cls):
|
||||||
|
_instance = {}
|
||||||
|
|
||||||
|
def inner():
|
||||||
|
if cls not in _instance:
|
||||||
|
_instance[cls] = cls()
|
||||||
|
return _instance[cls]
|
||||||
|
|
||||||
|
return inner
|
||||||
|
|
||||||
|
|
||||||
|
@singleton
|
||||||
|
class MediaMsg:
|
||||||
|
def __init__(self):
|
||||||
|
self.DB = None
|
||||||
|
self.cursor: sqlite3.Cursor = None
|
||||||
|
self.open_flag = False
|
||||||
|
self.init_database()
|
||||||
|
|
||||||
|
def init_database(self):
|
||||||
|
if not self.open_flag:
|
||||||
|
if os.path.exists(db_path):
|
||||||
|
self.DB = sqlite3.connect(db_path, check_same_thread=False)
|
||||||
|
# '''创建游标'''
|
||||||
|
self.cursor = self.DB.cursor()
|
||||||
|
self.open_flag = True
|
||||||
|
if lock.locked():
|
||||||
|
lock.release()
|
||||||
|
|
||||||
|
def get_media_buffer(self, reserved0):
|
||||||
|
pass
|
||||||
|
sql = '''
|
||||||
|
select Buf
|
||||||
|
from Media
|
||||||
|
where Reserved0 = ?
|
||||||
|
'''
|
||||||
|
try:
|
||||||
|
lock.acquire(True)
|
||||||
|
self.cursor.execute(sql, [reserved0])
|
||||||
|
return self.cursor.fetchone()
|
||||||
|
finally:
|
||||||
|
lock.release()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
db_path = './Msg/MediaMSG3.db'
|
||||||
|
media_msg_db = MediaMsg()
|
||||||
|
reserved = '823076859361714342'
|
||||||
|
buf = media_msg_db.get_media_buffer(reserved)
|
||||||
|
print(buf)
|
@ -49,7 +49,7 @@ class Msg:
|
|||||||
if not self.open_flag:
|
if not self.open_flag:
|
||||||
return None
|
return None
|
||||||
sql = '''
|
sql = '''
|
||||||
select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime
|
select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime,MsgSvrID
|
||||||
from MSG
|
from MSG
|
||||||
where StrTalker=?
|
where StrTalker=?
|
||||||
order by CreateTime
|
order by CreateTime
|
||||||
@ -65,7 +65,7 @@ class Msg:
|
|||||||
|
|
||||||
def get_messages_all(self):
|
def get_messages_all(self):
|
||||||
sql = '''
|
sql = '''
|
||||||
select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime
|
select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime,MsgSvrID
|
||||||
from MSG
|
from MSG
|
||||||
order by CreateTime
|
order by CreateTime
|
||||||
'''
|
'''
|
||||||
|
Loading…
Reference in New Issue
Block a user