diff --git a/pytools/runalyzer.py b/pytools/runalyzer.py index 4df14f930bee08c3fa601cf2420be15e1015acae..5ea244f57abdb1c2b1158c2324be0786210a4e51 100644 --- a/pytools/runalyzer.py +++ b/pytools/runalyzer.py @@ -105,16 +105,8 @@ class RunDB(object): if self.interactive: show() - def table_from_cursor(self, cursor): - from pytools import Table - tbl = Table() - tbl.add_row([column[0] for column in cursor.description]) - for row in cursor: - tbl.add_row(row) - return tbl - def print_cursor(self, cursor): - print self.table_from_cursor(cursor) + print table_from_cursor(cursor) @@ -145,6 +137,17 @@ def split_cursor(cursor): +def table_from_cursor(cursor): + from pytools import Table + tbl = Table() + tbl.add_row([column[0] for column in cursor.description]) + for row in cursor: + tbl.add_row(row) + return tbl + + + + class MagicRunDB(RunDB): def mangle_sql(self, qry): up_qry = qry.upper() @@ -224,6 +227,7 @@ def make_runalyzer_symbols(db): "dbscatter": db.scatter_cursor, "dbprint": db.print_cursor, "split_cursor": split_cursor, + "table_from_cursor": table_from_cursor, } @@ -314,6 +318,7 @@ Available Python symbols: dbscatter(cursor): make scatterplot result of cursor dbprint(cursor): print result of cursor split_cursor(cursor): x,y,data gather that .plot uses internally + table_from_cursor(cursor) """ elif cmd == "q": self.db.print_cursor(self.db.q(args))