batching together some transaction for performance sacke

This commit is contained in:
2024-08-07 11:08:39 +02:00
parent d37f451297
commit 71209e9b5f
2 changed files with 26 additions and 12 deletions

View File

@@ -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):
with sqlite3.connect("../db/sqlite3.db",timeout=10) as connection:
cursor = connection.cursor()
cursor.execute("UPDATE jobs SET viewed = '1' WHERE hash = ?",(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()
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)