diff options
Diffstat (limited to 'database/scripts/updatetestcaseids.py')
-rwxr-xr-x | database/scripts/updatetestcaseids.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/database/scripts/updatetestcaseids.py b/database/scripts/updatetestcaseids.py new file mode 100755 index 0000000..d11cb80 --- /dev/null +++ b/database/scripts/updatetestcaseids.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +""" +This script updates the testCaseId attribute of all rows in the benchmark table. +""" + +import sys +from dbaccess import setDatabase, execQuery, commit +from misc import findOrInsertId, getOptions, benchmarkToComponents + +# --- BEGIN Global functions ---------------------------------------------- +def printUsage(): + sys.stderr.write( + "usage: " + sys.argv[0] + " [--dbhost H] [--dbport P] --db D\n") +# --- END Global functions ---------------------------------------------- + + +# --- BEGIN Main program ---------------------------------------------- + +options, http_get = getOptions() + +if not ("db" in options): + printUsage() + sys.exit(1) + +setDatabase( + options["dbhost"] if "dbhost" in options else None, + options["dbport"] if "dbport" in options else None, + options["db"]) + +for benchmark_id, benchmark in execQuery( + "SELECT id, value FROM benchmark;", ()): + + test_case, test_function, data_tag = ( + benchmarkToComponents(benchmark)) + test_case_id = findOrInsertId("testCase", test_case) + + execQuery( + "UPDATE benchmark" + " SET testCaseId = %s" + " WHERE id = %s", (test_case_id, benchmark_id), False) + +commit() + +# --- END Main program ---------------------------------------------- |