comparison sqlpyPlus.py @ 65:047f82acdc8f

merging in bugfixes & pgsql additions
author catherine@cordelia
date Mon, 07 Apr 2008 09:51:18 -0400
parents 16618ff91c63 4f80329a1905
children ffd095bf466c 13edc2731d6b
comparison
equal deleted inserted replaced
64:1a52de2c541e 65:047f82acdc8f
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
190 from cmd2 import flagReader 190 from cmd2 import flagReader, Cmd
191 191
192 if float(sys.version[:3]) < 2.3: 192 if float(sys.version[:3]) < 2.3:
193 def enumerate(lst): 193 def enumerate(lst):
194 return zip(range(len(lst)), lst) 194 return zip(range(len(lst)), lst)
195 195
663 diffMergeSearcher.invoke(fnames[0], fnames[1]) 663 diffMergeSearcher.invoke(fnames[0], fnames[1])
664 664
665 bufferPosPattern = re.compile('\d+') 665 bufferPosPattern = re.compile('\d+')
666 rangeIndicators = ('-',':') 666 rangeIndicators = ('-',':')
667 667
668 def do_get(self, fname):
669 'Brings SQL commands from a file to the in-memory SQL buffer.'
670 numCommandsLoaded = self.load(fname)
671 if numCommandsLoaded:
672 self.do_list('%d -' % (len(self.history) - numCommandsLoaded))
673 def do_getrun(self, fname): 668 def do_getrun(self, fname):
674 'Brings SQL commands from a file to the in-memory SQL buffer, and executes them.' 669 'Brings SQL commands from a file to the in-memory SQL buffer, and executes them.'
675 numCommandsLoaded = self.do_load(fname) * -1 670 Cmd.do_load(self, fname)
676 if numCommandsLoaded:
677 for command in self.history[numCommandsLoaded:]:
678 self.onecmd_plus_hooks(command)
679 def do_psql(self, arg): 671 def do_psql(self, arg):
680 '''Shortcut commands emulating psql's backslash commands. 672 '''Shortcut commands emulating psql's backslash commands.
681 673
682 \c connect 674 \c connect
683 \d desc 675 \d desc
740 arg = ' '.join(args) 732 arg = ' '.join(args)
741 self.do_select('* from %s;%d' % (arg, nrows)) 733 self.do_select('* from %s;%d' % (arg, nrows))
742 734
743 def do_print(self, arg): 735 def do_print(self, arg):
744 'print VARNAME: Show current value of bind variable VARNAME.' 736 'print VARNAME: Show current value of bind variable VARNAME.'
745 if arg: 737 if arg:
746 if arg[0] == ':': 738 if arg[0] == ':':
747 arg = arg[1:] 739 arg = arg[1:]
748 try: 740 try:
749 self.stdout.write(self.binds[arg]+'\n') 741 self.stdout.write(self.binds[arg]+'\n')
750 except KeyError: 742 except KeyError: