数据库加锁避免多线程访问报错
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import os.path
|
||||
import sqlite3
|
||||
import time
|
||||
|
||||
DB = None
|
||||
cursor = None
|
||||
@@ -25,15 +26,24 @@ def is_database_exist():
|
||||
|
||||
|
||||
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()
|
||||
# pprint(result)
|
||||
# print(len(result))
|
||||
try:
|
||||
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()
|
||||
except:
|
||||
time.sleep(0.2)
|
||||
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()
|
||||
# DB.commit()
|
||||
return result
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user