Mercurial > sqlpython
comparison sqlpyPlus.py @ 12:7d27bb74ba90
holy cow, pull -f works
author | devlinjs@FA7CZA6N1254998.wrightpatterson.afmc.ds.af.mil |
---|---|
date | Tue, 18 Dec 2007 18:53:46 -0500 |
parents | cab368ea3ec8 |
children | 7c073794564a |
comparison
equal
deleted
inserted
replaced
11:cab368ea3ec8 | 12:7d27bb74ba90 |
---|---|
184 and c1.r_owner = c2.owner | 184 and c1.r_owner = c2.owner |
185 and c1.owner = :owner | 185 and c1.owner = :owner |
186 """ | 186 """ |
187 } | 187 } |
188 | 188 |
189 import sys, os, re, sqlpython, cx_Oracle, pyparsing | 189 import sys, os, re, sqlpython, cx_Oracle, pyparsing, flagReader |
190 | 190 |
191 if float(sys.version[:3]) < 2.3: | 191 if float(sys.version[:3]) < 2.3: |
192 def enumerate(lst): | 192 def enumerate(lst): |
193 return zip(range(len(lst)), lst) | 193 return zip(range(len(lst)), lst) |
194 | 194 |
195 class SoftwareSearcher(object): | 195 class SoftwareSearcher(object): |
196 def __init__(self, softwareList, purpose): | 196 def __init__(self, softwareList, purpose): |
197 self.softwareList = softwareList | 197 self.softwareList = softwareList |
198 self.purpose = purpose | 198 self.purpose = purpose |
199 self.software = None | 199 self.software = None |
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') \ | 422 'desc', 'comments', 'pull', 'refs', 'desc', 'triggers') \ |
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 |
660 val = self.cast(current, val.strip(';')) | 660 val = self.cast(current, val.strip(';')) |
661 print paramName, ' - was: ', current | 661 print paramName, ' - was: ', current |
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 def do_pull(self, arg): | 666 def do_pull(self, arg): |
666 "Displays source code." | 667 "Displays source code." |
667 | 668 |
669 options, arg = self.pullflags.parse(arg) | |
668 object_type, owner, object_name = self.resolve(arg.strip(self.terminator).upper()) | 670 object_type, owner, object_name = self.resolve(arg.strip(self.terminator).upper()) |
669 print "%s %s.%s" % (object_type, owner, object_name) | 671 print "%s %s.%s" % (object_type, owner, object_name) |
670 print self.curs.callfunc('DBMS_METADATA.GET_DDL', cx_Oracle.CLOB, | 672 print self.curs.callfunc('DBMS_METADATA.GET_DDL', cx_Oracle.CLOB, |
671 [object_type, object_name, owner]) | 673 [object_type, object_name, owner]) |
672 print self.curs.callfunc('DBMS_METADATA.GET_DEPENDENT_DDL', cx_Oracle.CLOB, | 674 if options.has_key('full'): |
673 [object_type, object_name, owner]) | 675 if object_type == 'TABLE': |
676 dependent_types = ['TRIGGER'] | |
677 else: | |
678 dependent_types = [] | |
679 for dependent_type in dependent_types: | |
680 print self.curs.callfunc('DBMS_METADATA.GET_DEPENDENT_DDL', cx_Oracle.CLOB, | |
681 [dependent_type, object_name, owner]) | |
674 | 682 |
675 def do_describe(self, arg): | 683 def do_describe(self, arg): |
676 "emulates SQL*Plus's DESCRIBE" | 684 "emulates SQL*Plus's DESCRIBE" |
677 object_type, owner, object_name = self.resolve(arg.strip(self.terminator).upper()) | 685 object_type, owner, object_name = self.resolve(arg.strip(self.terminator).upper()) |
678 print "%s %s.%s" % (object_type, owner, object_name) | 686 print "%s %s.%s" % (object_type, owner, object_name) |