comparison sqlpyPlus.py @ 92:fa8c9eb8908f

accepting command-line args
author catherine@cordelia
date Sun, 25 May 2008 01:35:08 -0400
parents 51e1fe3adf0e
children 5df8e2477ca3
comparison
equal deleted inserted replaced
91:51e1fe3adf0e 92:fa8c9eb8908f
339 print 'Bind variable %s not defined.' % (varname) 339 print 'Bind variable %s not defined.' % (varname)
340 return result 340 return result
341 341
342 class sqlpyPlus(sqlpython.sqlpython): 342 class sqlpyPlus(sqlpython.sqlpython):
343 defaultExtension = 'sql' 343 defaultExtension = 'sql'
344 shortcuts = {'?': 'help', '@': 'getrun', '!': 'shell', ':': 'setbind', '\\': 'psql'} 344 sqlpython.sqlpython.shortcuts.update({':': 'setbind', '\\': 'psql', '@': '_load'})
345 multilineCommands = '''select insert update delete tselect 345 multilineCommands = '''select insert update delete tselect
346 create drop alter'''.split() 346 create drop alter'''.split()
347 defaultFileName = 'afiedt.buf' 347 defaultFileName = 'afiedt.buf'
348 def __init__(self): 348 def __init__(self):
349 sqlpython.sqlpython.__init__(self) 349 sqlpython.sqlpython.__init__(self)
370 'desc', 'comments', 'pull', 'refs', 'desc', 'triggers', 'find') \ 370 'desc', 'comments', 'pull', 'refs', 'desc', 'triggers', 'find') \
371 and not hasattr(self, 'curs'): 371 and not hasattr(self, 'curs'):
372 print 'Not connected.' 372 print 'Not connected.'
373 return '', '', '' 373 return '', '', ''
374 return cmd, arg, line 374 return cmd, arg, line
375
376 do__load = Cmd.do_load
375 377
376 def onecmd_plus_hooks(self, line): 378 def onecmd_plus_hooks(self, line):
377 line = self.precmd(line) 379 line = self.precmd(line)
378 stop = self.onecmd(line) 380 stop = self.onecmd(line)
379 stop = self.postcmd(stop, line) 381 stop = self.postcmd(stop, line)
683 diffMergeSearcher.invoke(fnames[0], fnames[1]) 685 diffMergeSearcher.invoke(fnames[0], fnames[1])
684 686
685 bufferPosPattern = re.compile('\d+') 687 bufferPosPattern = re.compile('\d+')
686 rangeIndicators = ('-',':') 688 rangeIndicators = ('-',':')
687 689
688 def do_getrun(self, fname):
689 'Brings SQL commands from a file to the in-memory SQL buffer, and executes them.'
690 Cmd.do_load(self, fname)
691 def do_psql(self, arg): 690 def do_psql(self, arg):
692 '''Shortcut commands emulating psql's backslash commands. 691 '''Shortcut commands emulating psql's backslash commands.
693 692
694 \c connect 693 \c connect
695 \d desc 694 \d desc
696 \e edit 695 \e edit
697 \g run 696 \g run
698 \h help 697 \h help
699 \i getrun 698 \i load
700 \o spool 699 \o spool
701 \p list 700 \p list
702 \q quit 701 \q quit
703 \w save 702 \w save
704 \db _dir_tablespaces 703 \db _dir_tablespaces