Mercurial > sqlpython
changeset 241:d1f1022d2387
trying remark_begin
author | catherine@Elli.myhome.westell.com |
---|---|
date | Mon, 02 Mar 2009 06:38:30 -0500 |
parents | 6d9a65b442b5 |
children | 8866fe0706c3 |
files | setup.py sqlpython/mysqlpy.py sqlpython/sqlpyPlus.py sqlpython/sqlpython.py |
diffstat | 4 files changed, 35 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/setup.py Fri Feb 27 16:12:35 2009 -0500 +++ b/setup.py Mon Mar 02 06:38:30 2009 -0500 @@ -9,7 +9,7 @@ Operating System :: OS Independent""".splitlines() setup(name="sqlpython", - version="1.5.3", + version="1.6.0", description="Command-line interface to Oracle", long_description="Customizable alternative to Oracle's SQL*PLUS command-line interface", author="Luca Canali",
--- a/sqlpython/mysqlpy.py Fri Feb 27 16:12:35 2009 -0500 +++ b/sqlpython/mysqlpy.py Mon Mar 02 06:38:30 2009 -0500 @@ -1,5 +1,5 @@ #!/usr/bin/python -# MySqlPy V1.5.3 +# MySqlPy V1.6.0 # Author: Luca.Canali@cern.ch # #
--- a/sqlpython/sqlpyPlus.py Fri Feb 27 16:12:35 2009 -0500 +++ b/sqlpython/sqlpyPlus.py Mon Mar 02 06:38:30 2009 -0500 @@ -389,7 +389,32 @@ return cmd, arg, line do__load = Cmd.do_load - + + def do_remark_begin(self, line): + '''Wrapping a *single* SQL or PL/SQL statement in `REMARK_BEGIN` and `REMARK_END` + tells sqlpython to submit the enclosed code directly to Oracle as a single + unit of code. + + Without these markers, sqlpython fails to properly distinguish the beginning + and end of all but the simplest PL/SQL blocks, causing errors. sqlpython also + slows down when parsing long SQL statements as it tries to determine whether + the statement has ended yet; `REMARK_BEGIN` and `REMARK_END` allow it to skip this + parsing. + + REMARK_BEGIN and REMARK_END will be read as comments by standard SQL*Plus. + ''' + statement = [] + next = self.pseudo_raw_input(self.continuationPrompt) + while not next.lower().strip().startswith('remark_end'): + #and not next.lower().strip().startswith('--- end'): + statement.append(next) + next = self.pseudo_raw_input(self.continuationPrompt) + statement = self.parsed('\n'.join(statement)) + return self.onecmd(statement) + + def remark(self, line): + pass + def onecmd_plus_hooks(self, line): line = self.precmd(line) stop = self.onecmd(line) @@ -501,7 +526,7 @@ negator = pyparsing.Literal('!')('exclude') colNumber = pyparsing.Optional(negator) + pyparsing.Literal('.') + pyparsing.Word('-' + pyparsing.nums, pyparsing.nums)('column_number') colName = negator + pyparsing.Word('$_#' + pyparsing.alphas, '$_#' + pyparsing.alphanums)('column_name') - wildColName = pyparsing.Optional(negator) + pyparsing.Word('*%$_#' + pyparsing.alphas, '*%$_#' + pyparsing.alphanums, min=2)('column_name') + wildColName = pyparsing.Optional(negator) + pyparsing.Word('?*%$_#' + pyparsing.alphas, '?*%$_#' + pyparsing.alphanums, min=2)('column_name') wildSqlParser = colNumber ^ colName ^ wildColName wildSqlParser.ignore(pyparsing.cStyleComment).ignore(Parser.comment_def). \ ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString) @@ -520,6 +545,7 @@ p[0].column_number or '*' in p[0].column_name or '%' in p[0].column_name or + '?' in p[0].column_name or p[0].exclude] if not parseresults: return arg @@ -533,7 +559,8 @@ if col.column_name: finder = col.column_name.replace('*','.*') finder = finder.replace('%','.*') - colnames = [c for c in columns_available if re.match(finder, c, re.IGNORECASE)] + finder = finder.replace('?','.') + colnames = [c for c in columns_available if re.match(finder + '$', c, re.IGNORECASE)] elif col.column_number: idx = int(col.column_number) if idx > 0: @@ -1037,6 +1064,8 @@ lines = [line1] while True: line = self.pseudo_raw_input(self.continuationPrompt) + if line == 'EOF': + return if line.strip() == '/': try: self.curs.execute('\n'.join(lines))