sqlite: use executemany

avoid loop inserting the whole list in a single query
This commit is contained in:
mickael
2019-01-05 17:42:57 +00:00
parent f79a537279
commit cb342c3818

View File

@@ -172,8 +172,8 @@ class Proxywatchd():
def submit_collected(self):
query = 'UPDATE proxylist SET failed=?,tested=?,dronebl=?,country=?,proto=?,duration=? WHERE proxy=?'
for job in self.collected:
self.mysqlite.execute(query, (job.failcount, job.nextcheck, 1, "unknown", job.proto, job.duration, job.proxy))
args = [ (job.failcount, job.nextcheck, 1, 'unknown', job.proto, job.duration, job.proxy) for job in self.collected ]
self.mysqlite.executemany(query, args)
self.mysqlite.commit()
self.collected = []