Mercurial > sqlpython
changeset 195:4a3af9ac215f
wow, parsing is broken
author | catherine@dellzilla |
---|---|
date | Mon, 24 Nov 2008 18:53:51 -0500 |
parents | 932893dcf0c9 |
children | 7940955920a8 |
files | sqlpython/sqlpyPlus.py sqlpython/sqlpython.py |
diffstat | 2 files changed, 12 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/sqlpython/sqlpyPlus.py Mon Nov 24 16:26:11 2008 -0500 +++ b/sqlpython/sqlpyPlus.py Mon Nov 24 18:53:51 2008 -0500 @@ -350,9 +350,6 @@ if not givenBindVars.has_key(varname): print 'Bind variable %s not defined.' % (varname) return result - -def copyStatementEnding(newString, parsedOldStatement): - return newString + (parsedOldStatement.terminator or ';') + str(parsedOldStatement.rowlimit or '') class sqlpyPlus(sqlpython.sqlpython): defaultExtension = 'sql' @@ -372,8 +369,8 @@ self.stdoutBeforeSpool = sys.stdout self.spoolFile = None self.autobind = False - def default(self, arg): - sqlpython.sqlpython.default(self, arg) + #def default(self, arg): + # sqlpython.sqlpython.default(self, arg) # overrides cmd's parseline def parseline(self, line): @@ -545,8 +542,8 @@ def do_pull(self, arg, opts): """Displays source code.""" - arg = self.parsed(arg).unterminated.upper() - object_type, owner, object_name = self.resolve(arg) + target = arg.upper() + object_type, owner, object_name = self.resolve(target) if not object_type: return self.stdout.write("%s %s.%s\n" % (object_type, owner, object_name)) @@ -677,8 +674,8 @@ return object_type, owner, object_name, colName def do_resolve(self, arg): - arg = self.parsed(arg).unterminated.upper() - self.stdout.write(','.join(self.resolve(arg))+'\n') + target = arg.upper() + self.stdout.write(','.join(self.resolve(target))+'\n') def spoolstop(self): if self.spoolFile: @@ -793,8 +790,8 @@ self.do_select(self.parsed(sql, useTerminatorFrom=arg)) def do_head(self, arg): - sql = self.parsed('SELECT * FROM %s' % arg, useTerminatorFrom=arg) - sql.parsed.suffix = sql.parsed.suffix or '10' + sql = self.parsed('SELECT * FROM %s;' % arg, useTerminatorFrom=arg) + sql.parsed['suffix'] = sql.parsed.suffix or '10' self.do_select(sql) def do_print(self, arg): @@ -814,7 +811,6 @@ def do_setbind(self, arg): if not arg: return self.do_print(arg) - arg = self.parsed(arg).unterminated try: assigner, startat, endat = self.assignmentScanner.scanner.scanString(arg).next() except StopIteration: @@ -841,7 +837,6 @@ if arg[0] == ':': self.do_setbind(arg[1:]) else: - arg = self.parsed(arg).unterminated varsUsed = findBinds(arg, self.binds, {}) try: self.curs.execute('begin\n%s;end;' % arg, varsUsed) @@ -901,8 +896,7 @@ def do_grep(self, arg, opts): """grep PATTERN TABLE - search for term in any of TABLE's fields""" - arg = self.parsed(arg) - targetnames = arg.unterminated.split() + targetnames = arg.split() pattern = targetnames.pop(0) targets = [] for target in targetnames: @@ -932,8 +926,6 @@ def do_refs(self, arg): result = [] - parsed = self.parsed(arg) - arg = parsed.unterminated.upper() (type, owner, table_name) = self.resolve(arg) self.curs.execute("""SELECT constraint_name, r_owner, r_constraint_name FROM all_constraints
--- a/sqlpython/sqlpython.py Mon Nov 24 16:26:11 2008 -0500 +++ b/sqlpython/sqlpython.py Mon Nov 24 18:53:51 2008 -0500 @@ -94,10 +94,8 @@ terminatorSearchString = '|'.join('\\' + d.split()[0] for d in do_terminators.__doc__.splitlines()) def default(self, arg): - statement = self.parsed(arg) - self.query = statement.unterminated - self.varsUsed = sqlpyPlus.findBinds(self.query, self.binds, givenBindVars={}) - self.curs.execute(self.query, self.varsUsed) + self.varsUsed = sqlpyPlus.findBinds(arg, self.binds, givenBindVars={}) + self.curs.execute('%s %s' % (arg.parsed.command, arg.parsed.args), self.varsUsed) print '\nExecuted%s\n' % ((self.curs.rowcount > 0) and ' (%d rows)' % self.curs.rowcount or '') def do_commit(self, arg): @@ -106,7 +104,7 @@ self.default('rollback %s;' % (arg)) def do_quit(self, arg): if self.commit_on_exit and hasattr(self, 'curs'): - self.default('commit;') + self.default('commit') return cmd2.Cmd.do_quit(self, None) do_exit = do_quit do_q = do_quit