batching together some transaction for performance sacke
This commit is contained in:
parent
d37f451297
commit
71209e9b5f
@ -96,9 +96,16 @@ def writedb(jobs):
|
||||
cursor.execute("INSERT INTO jobs (star,tag,title,company,location,link,pubdate,hash,viewed) VALUES (?,?,?,?,?,?,?,?,?)",(job.starred,job.tag,job.title,job.company,job.location,job.link,job.date,hash1,0))
|
||||
|
||||
def viewedEntry(hash1):
|
||||
viewedEntry.list = []
|
||||
viewedEntry.list.append(hash1)
|
||||
print("viewedEntry.list:",viewedEntry.list)
|
||||
if len(viewedEntry.list) >= 5:
|
||||
with sqlite3.connect("../db/sqlite3.db",timeout=10) as connection:
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("UPDATE jobs SET viewed = '1' WHERE hash = ?",(hash1,))
|
||||
for x in viewedEntry.list:
|
||||
print("hash:",x)
|
||||
cursor.execute("UPDATE jobs SET viewed = '1' WHERE hash = ?",(x,))
|
||||
viewedEntry.list = []
|
||||
print("modified rows: ",cursor.rowcount)
|
||||
|
||||
|
||||
|
@ -16,6 +16,7 @@ class SqlQueryModel_editable(QSqlQueryModel):
|
||||
"""
|
||||
super().__init__()
|
||||
self.editables = editables
|
||||
self.updatelist = []
|
||||
|
||||
def flags(self, index):
|
||||
fl = QSqlQueryModel.flags(self, index)
|
||||
@ -41,16 +42,22 @@ class SqlQueryModel_editable(QSqlQueryModel):
|
||||
print(self.query().lastError().text())
|
||||
return result
|
||||
elif role == 1001:
|
||||
result = 0
|
||||
self.updatelist.append(value)
|
||||
print(self.updatelist)
|
||||
if len(self.updatelist) >= 5:
|
||||
for x in self.updatelist:
|
||||
print("Atempt flaging view")
|
||||
q = QSqlQuery("UPDATE jobs SET viewed = '1' WHERE hash = {}".format(value))
|
||||
print("QSQLQuery: ", "UPDATE jobs SET viewed = '1' WHERE hash = {}".format(value))
|
||||
q = QSqlQuery("UPDATE jobs SET viewed = '1' WHERE hash = {}".format(x))
|
||||
print("QSQLQuery: ", "UPDATE jobs SET viewed = '1' WHERE hash = {}".format(x))
|
||||
result = q.exec_()
|
||||
if result:
|
||||
self.query().exec_()
|
||||
# print("filter_value:",filter_value)
|
||||
else:
|
||||
print("Error:", self.query().lastError().text())
|
||||
return result
|
||||
self.updatelist = []
|
||||
return result
|
||||
return QSqlQueryModel.setData(self, index, value, role)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user