Mercurial > sqlpython
changeset 302:ee5bec997cd3
@@ working
author | catherine@Elli.myhome.westell.com |
---|---|
date | Tue, 24 Mar 2009 19:45:27 -0400 |
parents | 154c2e44abce |
children | f7daca26cc00 |
files | sqlpython/sqlpyPlus.py |
diffstat | 1 files changed, 12 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/sqlpython/sqlpyPlus.py Tue Mar 24 16:21:16 2009 -0400 +++ b/sqlpython/sqlpyPlus.py Tue Mar 24 19:45:27 2009 -0400 @@ -23,6 +23,7 @@ - catherinedevlin.blogspot.com May 31, 2006 """ +#TODO: html escaping; prompt/accept; sqlpath; LOCAL name; @@ import sys, os, re, sqlpython, cx_Oracle, pyparsing, re, completion, datetime, pickle, binascii, subprocess from cmd2 import Cmd, make_option, options, Statekeeper, Cmd2TestCase from output_templates import output_templates @@ -513,14 +514,17 @@ ''' return Cmd.do_py(self, arg) + argument_grammar = pyparsing.QuotedString('"') | pyparsing.QuotedString("'") \ + | pyparsing.Word(pyparsing.printables) def do_get(self, args): """ `get {script.sql}` or `@{script.sql}` runs the command(s) in {script.sql}. If additional arguments are supplied, they are assigned to &1, &2, etc. """ - fname, args = args.split()[0], args.split()[1:] - for (idx, arg) in enumerate(args): - self.substvars[str(idx+1)] = arg + args = args.split(None,1) + fname, args = args[0], (args[1:] or [''])[0] + for (idx, arg) in enumerate(self.argument_grammar.scanString(args)): + self.substvars[str(idx+1)] = arg[0][0] return Cmd.do__load(self, fname) def onecmd_plus_hooks(self, line): @@ -533,12 +537,6 @@ self.curs.callproc('dbms_output.enable', []) else: self.curs.callproc('dbms_output.disable', []) - - def do_shortcuts(self,arg): - """Lists available first-character shortcuts - (i.e. '!dir' is equivalent to 'shell dir')""" - for (scchar, scto) in self.shortcuts.items(): - print '%s: %s' % (scchar, scto) tableNameFinder = re.compile(r'from\s+([\w$#_"]+)', re.IGNORECASE | re.MULTILINE | re.DOTALL) inputStatementFormatters = { @@ -713,7 +711,7 @@ prompt = '' varname = args.lower().split()[0] self.substvars[varname] = self.pseudo_raw_input(prompt) - + def ampersand_substitution(self, raw, regexpr, isglobal): subst = regexpr.search(raw) while subst: @@ -1278,6 +1276,10 @@ except StopIteration: return ''.join(arg.split()[:1]), '' + def do_column(self, arg): + 'COLUMN keyword not supported by sqlpython' + print self.do_column.__doc__ + assignmentScanner = Parser(pyparsing.Literal(':=') ^ '=') def interpret_variable_assignment(self, arg): '''