Various poorly documented changes to tko frontend. Sorry
From: Vladimir Samarskiy <vsamarsk@google.com>
Signed-off-by: Martin Bligh <mbligh@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@1437 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/tko/db.py b/tko/db.py
index 3adbdfa..14e7c1b 100644
--- a/tko/db.py
+++ b/tko/db.py
@@ -1,6 +1,9 @@
import re, os, sys, types
from common import global_config
+class MySQLTooManyRows(Exception):
+ pass
+
class db_sql:
def __init__(self, debug = False, autocommit=True, host = None,
@@ -59,8 +62,8 @@
return self.cur.fetchall()[0][0]
- def select(self, fields, table, where, wherein={}, distinct = False,
- group_by = None):
+ def select(self, fields, table, where, wherein={},
+ distinct = False, group_by = None, max_rows = None):
"""\
This selects all the fields requested from a
specific table with a particular where clause.
@@ -109,7 +112,10 @@
cmd.append(' GROUP BY ' + group_by)
self.dprint('%s %s' % (' '.join(cmd), values))
- self.cur.execute(' '.join(cmd), values)
+ numRec = self.cur.execute(' '.join(cmd), values)
+ if max_rows != None and numRec > max_rows:
+ msg = 'Exceeded allowed number of records'
+ raise MySQLTooManyRows(msg)
return self.cur.fetchall()