Mercurial > sqlpython
comparison sqlpyPlus.py @ 117:dfb71885dd41
everything seems working
author | catherine@Elli.myhome.westell.com |
---|---|
date | Fri, 04 Jul 2008 18:54:26 -0400 |
parents | 6e346ae994b9 |
children | 0776ceacfc79 |
comparison
equal
deleted
inserted
replaced
116:6e346ae994b9 | 117:dfb71885dd41 |
---|---|
506 # what about quote-enclosed? | 506 # what about quote-enclosed? |
507 | 507 |
508 legalOracle = re.compile('[a-zA-Z_$#]') | 508 legalOracle = re.compile('[a-zA-Z_$#]') |
509 | 509 |
510 rowlimitPattern = pyparsing.Word(pyparsing.nums)('rowlimit') | 510 rowlimitPattern = pyparsing.Word(pyparsing.nums)('rowlimit') |
511 terminators = pyparsing.oneOf('; \\s \\S \\c \\C \\t \\x \\h \n/\n')('terminator') + \ | 511 terminatorPattern = pyparsing.oneOf('; \\s \\S \\c \\C \\t \\x \\h \n/\n')('terminator') + \ |
512 pyparsing.Optional(rowlimitPattern) | 512 pyparsing.Optional(rowlimitPattern) |
513 def do_select(self, arg, bindVarsIn=None, override_terminator=None): | 513 def do_select(self, arg, bindVarsIn=None, override_terminator=None): |
514 """Fetch rows from a table. | 514 """Fetch rows from a table. |
515 | 515 |
516 Limit the number of rows retrieved by appending | 516 Limit the number of rows retrieved by appending |
517 an integer after the terminator | 517 an integer after the terminator |
520 Output may be formatted by choosing an alternative terminator | 520 Output may be formatted by choosing an alternative terminator |
521 ("help terminators" for details) | 521 ("help terminators" for details) |
522 """ | 522 """ |
523 bindVarsIn = bindVarsIn or {} | 523 bindVarsIn = bindVarsIn or {} |
524 statement = self.parsed('select ' + arg) | 524 statement = self.parsed('select ' + arg) |
525 self.query = statement.statement | 525 self.query = statement.unterminated |
526 if override_terminator: | 526 if override_terminator: |
527 statement['terminator'] = override_terminator | 527 statement['terminator'] = override_terminator |
528 statement['rowlimit'] = int(statement.rowlimit or 0) | 528 statement['rowlimit'] = int(statement.rowlimit or 0) |
529 try: | 529 try: |
530 self.varsUsed = findBinds(self.query, self.binds, bindVarsIn) | 530 self.varsUsed = findBinds(self.query, self.binds, bindVarsIn) |
531 self.curs.execute(self.query, self.varsUsed) | 531 self.curs.execute(self.query, self.varsUsed) |
532 self.rows = self.curs.fetchmany(min(self.maxfetch, (statement.rowlimit or self.maxfetch))) | 532 self.rows = self.curs.fetchmany(min(self.maxfetch, (statement.rowlimit or self.maxfetch))) |
533 self.desc = self.curs.description | 533 self.desc = self.curs.description |
534 self.rc = self.curs.rowcount | 534 self.rc = self.curs.rowcount |
535 if self.rc > 0: | 535 if self.rc > 0: |
536 self.stdout.write('\n%s\n' % (self.output(statement.terminator, rowlimit))) | 536 self.stdout.write('\n%s\n' % (self.output(statement.terminator, statement.rowlimit))) |
537 if self.rc == 0: | 537 if self.rc == 0: |
538 print '\nNo rows Selected.\n' | 538 print '\nNo rows Selected.\n' |
539 elif self.rc == 1: | 539 elif self.rc == 1: |
540 print '\n1 row selected.\n' | 540 print '\n1 row selected.\n' |
541 if self.autobind: | 541 if self.autobind: |