# HG changeset patch # User catherine@cordelia # Date 1208203019 14400 # Node ID 7bb52cc35332345f972d6a6d1883d0c067499b54 # Parent 13edc2731d6b7beb8bf5bc882d60dfafcea13036 before reworking setbind diff -r 13edc2731d6b -r 7bb52cc35332 sqlpyPlus.py --- a/sqlpyPlus.py Mon Apr 14 15:32:03 2008 -0400 +++ b/sqlpyPlus.py Mon Apr 14 15:56:59 2008 -0400 @@ -327,7 +327,6 @@ 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 @@ -757,24 +756,24 @@ elif len(args) > 2 and args[1] in ('=',':='): var, val = args[0], args[2] if val[0] == val[-1] == "'" and len(val) > 1: - val = val[1:-1] - self.binds[var] = val + val = val[1:-1] # stripping quotes; is that wise? + self.binds[var] = val # but what if val is a function call? else: print 'Could not parse ', args + def do_exec(self, arg): if arg[0] == ':': self.do_setbind(arg[1:]) else: - self.default('exec %s' % arg) + try: + self.curs.execute('begin\n%s;end;' % arg) + except Exception, e: + print e + ''' + exec :x := 'box' + exec :y := sysdate + ''' - 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: