summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2011-01-31 18:54:05 +0100
committerJoão Abecasis <joao.abecasis@nokia.com>2011-02-02 14:30:18 +0100
commitdb0f8fa9537111abd7c0f2ae2686de532fbbda41 (patch)
tree15f1ec66d00ba77abf267ff319ac64c842f2ed2c
parentcd437e059cd7fe64939e96c2091f78c69aacd03b (diff)
Get id for newly inserted rows as they're inserted
Reviewed-By: jasplin
-rwxr-xr-xscripts/uploadresults.py7
1 files 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]