diff --git a/plugins/Chart/ChartCollector.py b/plugins/Chart/ChartCollector.py index 776343af..82e54bb6 100644 --- a/plugins/Chart/ChartCollector.py +++ b/plugins/Chart/ChartCollector.py @@ -146,8 +146,7 @@ class ChartCollector(object): s = time.time() cur = self.db.getCursor() - cur.cursor.executemany("INSERT INTO data (type_id, value, date_added) VALUES (?, ?, ?)", values) - cur.close() + cur.executemany("INSERT INTO data (type_id, value, date_added) VALUES (?, ?, ?)", values) self.log.debug("Global collectors inserted in %.3fs" % (time.time() - s)) def collectSites(self, sites, collectors, last_values): @@ -163,8 +162,7 @@ class ChartCollector(object): s = time.time() cur = self.db.getCursor() - cur.cursor.executemany("INSERT INTO data (type_id, site_id, value, date_added) VALUES (?, ?, ?, ?)", values) - cur.close() + cur.executemany("INSERT INTO data (type_id, site_id, value, date_added) VALUES (?, ?, ?, ?)", values) self.log.debug("Site collectors inserted in %.3fs" % (time.time() - s)) def collector(self): diff --git a/plugins/Chart/ChartDb.py b/plugins/Chart/ChartDb.py index 9dd4d3db..66a22082 100644 --- a/plugins/Chart/ChartDb.py +++ b/plugins/Chart/ChartDb.py @@ -48,15 +48,15 @@ class ChartDb(Db): def getTypeId(self, name): if name not in self.types: - self.execute("INSERT INTO type ?", {"name": name}) - self.types[name] = self.cur.cursor.lastrowid + res = self.execute("INSERT INTO type ?", {"name": name}) + self.types[name] = res.lastrowid return self.types[name] def getSiteId(self, address): if address not in self.sites: - self.execute("INSERT INTO site ?", {"address": address}) - self.sites[address] = self.cur.cursor.lastrowid + res = self.execute("INSERT INTO site ?", {"address": address}) + self.sites[address] = res.lastrowid return self.sites[address]