Extensions to SQL abstractions
Signed-off-by: Martin J. Bligh <mbligh@google.com>
Add more generalized select statement, allow where to be a
string as instead of a dictionary, add an update function.
git-svn-id: http://test.kernel.org/svn/autotest/trunk@755 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/tko/frontend.py b/tko/frontend.py
index c48c5a1..7ffe8d2 100755
--- a/tko/frontend.py
+++ b/tko/frontend.py
@@ -64,6 +64,15 @@
return tests
+ @classmethod
+ def select_sql(klass, db, sql, values):
+ fields = ['test_idx', 'job_idx', 'test', 'subdir',
+ 'kernel_idx', 'status', 'reason', 'machine_idx']
+ fields = ['t.'+field for field in fields]
+ rows = db.select_sql(','.join(fields), 'tests', sql, values)
+ return [klass(db, *row) for row in rows]
+
+
def __init__(self, db, test_idx, job_idx, testname, subdir, kernel_idx, status_num, reason, machine_idx):
self.idx = test_idx
self.job = job(db, job_idx)