From 06766a4b5b8d05910d28a3672f61b7dd8acef24f Mon Sep 17 00:00:00 2001 From: Steve Dougherty Date: Sun, 9 Dec 2012 00:47:36 -0500 Subject: [PATCH] Fix using Connection as Cursor. --- probe.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/probe.py b/probe.py index 7aad4e4..7c8d79f 100644 --- a/probe.py +++ b/probe.py @@ -61,11 +61,13 @@ def insert(args, probe_type, result, duration): elif probe_type == "IDENTIFIER": db.execute("insert into identifier(time, htl, identifier, percent, duration) values(?, ?, ?, ?, ?)", (now, htl, result[PROBE_IDENTIFIER], result[UPTIME_PERCENT], duration)) elif probe_type == "LINK_LENGTHS": + cur = db.cursor() lengths = split(result[LINK_LENGTHS], ';') - db.execute("insert into peer_count(time, htl, peers, duration) values(?, ?, ?, ?)", (now, htl, len(lengths), duration)) - new_id = db.lastrowid + cur.execute("insert into peer_count(time, htl, peers, duration) values(?, ?, ?, ?)", (now, htl, len(lengths), duration)) + new_id = cur.lastrowid for length in lengths: - db.execute("insert into link_lengths(time, htl, length, id) values(?, ?, ?, ?)", (now, htl, length, new_id)) + cur.execute("insert into link_lengths(time, htl, length, id) values(?, ?, ?, ?)", (now, htl, length, new_id)) + cur.close() elif probe_type == "LOCATION": db.execute("insert into location(time, htl, location, duration) values(?, ?, ?, ?)", (now, htl, result[LOCATION], duration)) elif probe_type == "STORE_SIZE":