comparison sqlpyPlus.py @ 27:ca6f34be3397

working on ed
author devlinjs@FA7CZA6N1254998.wrightpatterson.afmc.ds.af.mil
date Wed, 19 Dec 2007 16:22:53 -0500
parents bb3fb24b6f5f
children d3b2f9c6e536
comparison
equal deleted inserted replaced
26:bb3fb24b6f5f 27:ca6f34be3397
693 runme = self.last_matching(arg) 693 runme = self.last_matching(arg)
694 print runme 694 print runme
695 self.onecmd_plus_hooks(runme) 695 self.onecmd_plus_hooks(runme)
696 do_r = do_run 696 do_r = do_run
697 697
698 def do_ed(self, arg):
699 'ed [N]: brings up SQL from N commands ago in text editor, and puts result in SQL buffer.'
700 fname = 'sqlpython_temp.sql'
701 buffer = self.last_matching(arg)
702 if not buffer:
703 print 'Nothing appropriate in buffer to edit.'
704 return
705 f = open(fname, 'w')
706 f.write(buffer)
707 f.close()
708 editSearcher.invoke(fname)
709 self.load(fname)
710 do_edit = do_ed
711 def do_get(self, fname): 698 def do_get(self, fname):
712 'Brings SQL commands from a file to the in-memory SQL buffer.' 699 'Brings SQL commands from a file to the in-memory SQL buffer.'
713 numCommandsLoaded = self.load(fname) 700 numCommandsLoaded = self.load(fname)
714 if numCommandsLoaded: 701 if numCommandsLoaded:
715 self.do_list('%d -' % (len(self.history) - numCommandsLoaded)) 702 self.do_list('%d -' % (len(self.history) - numCommandsLoaded))
745 try: 732 try:
746 self.onecmd('%s %s' % (commands[abbrev], args)) 733 self.onecmd('%s %s' % (commands[abbrev], args))
747 self.onecmd('q') 734 self.onecmd('q')
748 except KeyError: 735 except KeyError:
749 print 'psql command \%s not yet supported.' % abbrev 736 print 'psql command \%s not yet supported.' % abbrev
750 def do_save(self, fname):
751 'save FILENAME: Saves most recent SQL command to disk.'
752 try:
753 f = open(fname, 'w')
754 f.write(self.sqlBuffer[-1])
755 f.close()
756 except Exception, e:
757 print 'Error saving %s: %s' % (fname, str(e))
758 737
759 def do_print(self, arg): 738 def do_print(self, arg):
760 'print VARNAME: Show current value of bind variable VARNAME.' 739 'print VARNAME: Show current value of bind variable VARNAME.'
761 if arg: 740 if arg:
762 if arg[0] == ':': 741 if arg[0] == ':':