WeChatMsg/app/DataBase/micro_msg.py

32 lines
846 B
Python
Raw Normal View History

2023-11-15 21:57:29 +08:00
import os.path
2023-11-12 21:51:33 +08:00
import sqlite3
2023-11-15 21:57:29 +08:00
DB = None
cursor = None
micromsg_path = "./app/Database/Msg/MicroMsg.db"
if os.path.exists(micromsg_path):
DB = sqlite3.connect(micromsg_path, check_same_thread=False)
# '''创建游标'''
cursor = DB.cursor()
def is_database_exist():
return os.path.exists(micromsg_path)
2023-11-12 21:51:33 +08:00
def get_contact():
sql = '''select UserName,Alias,Type,Remark,NickName,PYInitial,RemarkPYInitial,ContactHeadImgUrl.smallHeadImgUrl,ContactHeadImgUrl.bigHeadImgUrl
from Contact inner join ContactHeadImgUrl on Contact.UserName = ContactHeadImgUrl.usrName
where Type=3 and Alias is not null
order by PYInitial
'''
cursor.execute(sql)
result = cursor.fetchall()
2023-11-15 21:57:29 +08:00
# pprint(result)
# print(len(result))
2023-11-12 21:51:33 +08:00
return result
if __name__ == '__main__':
get_contact()