Skip to content
Snippets Groups Projects
Commit c6220244 authored by Pavel Kácha's avatar Pavel Kácha
Browse files

Update to more strict MySQLdb API (thx to bodik@cesnet.cz)

parent 5bd0ea9c
No related branches found
No related tags found
No related merge requests found
......@@ -757,7 +757,7 @@ class MySQL(ObjectBase):
def getLastReceivedId(self, client):
res = self.query("SELECT event_id as id FROM last_events WHERE client_id = %s ORDER BY last_events.id DESC LIMIT 1", client.id, commit=True).fetchall()
res = self.query("SELECT event_id as id FROM last_events WHERE client_id = %s ORDER BY last_events.id DESC LIMIT 1", (client.id,), commit=True).fetchall()
try:
row = res[0]
except IndexError:
......@@ -791,15 +791,15 @@ class MySQL(ObjectBase):
def purge_lastlog(self, days):
try:
self.query(
crs = self.query(
"DELETE FROM last_events "
" USING last_events LEFT JOIN ("
" SELECT MAX(id) AS last FROM last_events"
" GROUP BY client_id"
" ) AS maxids ON last=id"
" WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL %s DAY) AND last IS NULL",
days)
affected = self.con.affected_rows()
(days,))
affected = crs.rowcount
self.con.commit()
except Exception as e:
self.con.rollback()
......@@ -809,10 +809,10 @@ class MySQL(ObjectBase):
def purge_events(self, days):
try:
self.query(
crs = self.query(
"DELETE FROM events WHERE received < DATE_SUB(CURDATE(), INTERVAL %s DAY)",
days)
affected = self.con.affected_rows()
(days,))
affected = crs.rowcount
self.con.commit()
except Exception as e:
self.con.rollback()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment