Mercurial > sqlpython
changeset 272:fee766daa57b
yay py works fully
author | catherine@Elli.myhome.westell.com |
---|---|
date | Wed, 18 Mar 2009 18:27:16 -0400 |
parents | fbe23b635300 |
children | 9d67065ea030 |
files | sqlpython/sqlpyPlus.py |
diffstat | 1 files changed, 11 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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 <command>: 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)