batching together some transaction for performance sacke
This commit is contained in:
13
lib/db.py
13
lib/db.py
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user