Mercurial > sqlpython
comparison sqlpyPlus.py @ 14:1300a997d319
find works
author | devlinjs@FA7CZA6N1254998.wrightpatterson.afmc.ds.af.mil |
---|---|
date | Tue, 18 Dec 2007 19:15:58 -0500 |
parents | 7c073794564a |
children | 9c7df9f825a1 |
comparison
equal
deleted
inserted
replaced
13:7c073794564a | 14:1300a997d319 |
---|---|
417 else: | 417 else: |
418 i, n = 0, len(line) | 418 i, n = 0, len(line) |
419 while i < n and line[i] in self.identchars: i = i+1 | 419 while i < n and line[i] in self.identchars: i = i+1 |
420 cmd, arg = line[:i], line[i:].strip() | 420 cmd, arg = line[:i], line[i:].strip() |
421 if cmd.lower() in ('select', 'sleect', 'insert', 'update', 'delete', 'describe', | 421 if cmd.lower() in ('select', 'sleect', 'insert', 'update', 'delete', 'describe', |
422 'desc', 'comments', 'pull', 'refs', 'desc', 'triggers') \ | 422 'desc', 'comments', 'pull', 'refs', 'desc', 'triggers', 'find') \ |
423 and not hasattr(self, 'curs'): | 423 and not hasattr(self, 'curs'): |
424 print 'Not connected.' | 424 print 'Not connected.' |
425 return '', '', '' | 425 return '', '', '' |
426 return cmd, arg, line | 426 return cmd, arg, line |
427 | 427 |
662 setattr(self, paramName.lower(), val) | 662 setattr(self, paramName.lower(), val) |
663 print 'now: ', val | 663 print 'now: ', val |
664 | 664 |
665 pullflags = flagReader.FlagSet([flagReader.Flag('full')]) | 665 pullflags = flagReader.FlagSet([flagReader.Flag('full')]) |
666 def do_pull(self, arg): | 666 def do_pull(self, arg): |
667 "Displays source code (pull -f to get dependent objects as well)." | 667 """Displays source code. |
668 | |
669 --full, -f: get dependent objects as well""" | |
668 | 670 |
669 options, arg = self.pullflags.parse(arg) | 671 options, arg = self.pullflags.parse(arg) |
670 object_type, owner, object_name = self.resolve(arg.strip(self.terminator).upper()) | 672 object_type, owner, object_name = self.resolve(arg.strip(self.terminator).upper()) |
671 print "%s %s.%s" % (object_type, owner, object_name) | 673 print "%s %s.%s" % (object_type, owner, object_name) |
672 print self.curs.callfunc('DBMS_METADATA.GET_DDL', cx_Oracle.CLOB, | 674 print self.curs.callfunc('DBMS_METADATA.GET_DDL', cx_Oracle.CLOB, |
677 print self.curs.callfunc('DBMS_METADATA.GET_DEPENDENT_DDL', cx_Oracle.CLOB, | 679 print self.curs.callfunc('DBMS_METADATA.GET_DEPENDENT_DDL', cx_Oracle.CLOB, |
678 [dependent_type, object_name, owner]) | 680 [dependent_type, object_name, owner]) |
679 except cx_Oracle.DatabaseError: | 681 except cx_Oracle.DatabaseError: |
680 pass | 682 pass |
681 | 683 |
684 findflags = flagReader.FlagSet([flagReader.Flag('insensitive')]) | |
685 def do_find(self, arg): | |
686 """Finds argument in source code. | |
687 | |
688 --insensitive, -i: case-insensitive search""" | |
689 | |
690 options, arg = self.findflags.parse(arg) | |
691 if options.has_key('insensitive'): | |
692 searchfor = "LOWER(text)" | |
693 arg = arg.lower() | |
694 else: | |
695 searchfor = "text" | |
696 print "* from all_source where %s like %%%s%%" % (searchfor, arg) | |
697 self.do_select("* from all_source where %s like '%%%s%%'" % (searchfor, arg)) | |
698 | |
682 def do_describe(self, arg): | 699 def do_describe(self, arg): |
683 "emulates SQL*Plus's DESCRIBE" | 700 "emulates SQL*Plus's DESCRIBE" |
684 object_type, owner, object_name = self.resolve(arg.strip(self.terminator).upper()) | 701 object_type, owner, object_name = self.resolve(arg.strip(self.terminator).upper()) |
685 print "%s %s.%s" % (object_type, owner, object_name) | 702 print "%s %s.%s" % (object_type, owner, object_name) |
686 descQ = descQueries.get(object_type) | 703 descQ = descQueries.get(object_type) |