From db0f8fa9537111abd7c0f2ae2686de532fbbda41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 31 Jan 2011 18:54:05 +0100 Subject: Get id for newly inserted rows as they're inserted Reviewed-By: jasplin --- scripts/uploadresults.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/uploadresults.py b/scripts/uploadresults.py index 08e496e..31a7caf 100755 --- a/scripts/uploadresults.py +++ b/scripts/uploadresults.py @@ -172,12 +172,11 @@ def findOrInsertId(table, value, *args): query += ") VALUES ('" + str(value) + "'"; for i in range(0, len(args), 2): query += ", " + str(args[i + 1]) - query += ");"; - execQuery(query, False) # ... and retrieve ID: - query_result = execQuery( - "SELECT id FROM " + table + " WHERE value = '" + str(value) + "';") + query += ") RETURNING id;" + query_result = execQuery(query) + assert len(query_result) == 1 #print "returning new ID: >" + str(query_result[0][0]) + "<" return query_result[0][0] -- cgit v1.2.3