# HG changeset patch # User catherine@Elli.myhome.westell.com # Date 1237415236 14400 # Node ID fee766daa57be9d2d808186c219b1986c55f9c8a # Parent fbe23b635300fd2b977e539732e3abe4ec89b765 yay py works fully diff -r fbe23b635300 -r fee766daa57b sqlpython/sqlpyPlus.py --- a/sqlpython/sqlpyPlus.py Wed Mar 18 15:31:52 2009 -0400 +++ b/sqlpython/sqlpyPlus.py Wed Mar 18 18:27:16 2009 -0400 @@ -351,8 +351,8 @@ class Result(tuple): def __str__(self): - for colname in self.resultset.colnames: - return '%s: %s' % (colname, getattr(self.colname)) + return '\n'.join('%s: %s' % (colname, self[idx]) + for (idx, colname) in enumerate(self.resultset.colnames)) def __getattr__(self, attr): attr = attr.lower() try: @@ -456,7 +456,15 @@ statement.append(next) next = self.pseudo_raw_input(self.continuation_prompt) return self.onecmd('\n'.join(statement)) - + + def do_py(self, arg): + ''' + py : Executes a Python command. + py: Enters interactive Python mode (end with `\py`). + Past SELECT results are stored in list `r`; most recent resultset is `r[-1]`. + ''' + Cmd.__py__(self, arg) + def onecmd_plus_hooks(self, line): line = self.precmd(line) stop = self.onecmd(line)