Mercurial > sqlpython
changeset 70:13edc2731d6b
begin, declare
author | catherine@cordelia |
---|---|
date | Mon, 14 Apr 2008 15:32:03 -0400 |
parents | e5054588bf9b |
children | 7bb52cc35332 |
files | sqlpyPlus.py |
diffstat | 1 files changed, 27 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/sqlpyPlus.py Mon Apr 07 09:56:25 2008 -0400 +++ b/sqlpyPlus.py Mon Apr 14 15:32:03 2008 -0400 @@ -327,6 +327,7 @@ pipeSeparator = Parser(pyparsing.SkipTo((pyparsing.Literal('|') ^ pyparsing.StringEnd()), include=True), retainSeparator=False) bindScanner = Parser(pyparsing.Literal(':') + pyparsing.Word( pyparsing.alphanums + "_$#" )) commandSeparator = Parser(pyparsing.SkipTo((pyparsing.Literal(';') ^ pyparsing.StringEnd()), include=True)) +anonBlockScanner = Parser(pyparsing.SkipTo(pyparsing.CaselessKeyword('END'))) def findBinds(target, existingBinds, givenBindVars = {}): result = givenBindVars @@ -766,6 +767,32 @@ else: self.default('exec %s' % arg) + def anonBlockDone(self, statement): + try: + p = anonBlockScanner.scanner.parseString(statement) + s = 1 + except pyparsing.ParseException: + return False + return True + + def anon_plsql(self, line1): + lines = [line1] + while True: + line = self.pseudo_raw_input(self.continuationPrompt) + if line.strip() == '/': + try: + self.curs.execute('\n'.join(lines)) + except Exception, e: + print e + return + lines.append(line) + + def do_begin(self, arg): + self.anon_plsql('begin ' + arg) + + def do_declare(self, arg): + self.anon_plsql('declare ' + arg) + def do_cat(self, arg): targets = arg.split() for target in targets: