Permalink
Browse files

Adding the query time and number of results.

  • Loading branch information...
1 parent 8c92e00 commit b24a54c2286883a6a31670a957b2a9edabbe4ecb @mrjbq7 mrjbq7 committed Jun 1, 2010
Showing with 8 additions and 0 deletions.
  1. +4 −0 tracsql/templates/sql.html
  2. +4 −0 tracsql/web_ui.py
@@ -33,6 +33,10 @@
<input type="checkbox" name="raw" />Raw Output
</py:otherwise>
</py:choose>
+</td><td align="right">
+<py:if test="not error">
+<b>${len(rows)}</b> results (<b>${took}</b> seconds)
+</py:if>
</td></tr>
</table>
</form>
View
@@ -108,6 +108,7 @@ def _process(self, req, cursor, data):
raw = req.args.get('raw', '')
cols = rows = []
+ took = 0
error = None
if re.search('.*delete|drop|insert|replace|set|update.*', sql,
@@ -116,9 +117,11 @@ def _process(self, req, cursor, data):
elif sql.strip():
try:
+ start = time.time()
cursor.execute(sql)
cols = map(lambda x: x[0], cursor.description)
rows = cursor.fetchall()[:1000]
+ took = '%.3f' % (time.time() - start)
except BaseException, e:
error = e.message
@@ -147,6 +150,7 @@ def _process(self, req, cursor, data):
data['error'] = error
data['cols'] = cols
data['rows'] = rows
+ data['took'] = took
data['raw'] = raw
return 'sql.html', data, None

0 comments on commit b24a54c

Please sign in to comment.