comparison mysqlpy.py @ 94:5df8e2477ca3

command-line args working
author catherine@cordelia
date Sun, 25 May 2008 05:22:34 -0400
parents f40bb62c625f
children 9c5371b5edf4
comparison
equal deleted inserted replaced
93:f40bb62c625f 94:5df8e2477ca3
13 13
14 class mysqlpy(sqlpyPlus): 14 class mysqlpy(sqlpyPlus):
15 ''' 15 '''
16 MySqlPy V1.3 - 'sqlplus in python' 16 MySqlPy V1.3 - 'sqlplus in python'
17 Author: Luca.Canali@cern.ch 17 Author: Luca.Canali@cern.ch
18 Rev: 1.3.0, 17-Oct-07 18 Rev: 1.4.4, 28-May-08
19 19
20 Companion of SqlPython, a python module that reproduces Oracle's command line within python 20 Companion of SqlPython, a python module that reproduces Oracle's command line within python
21 and sqlpyPlus. Major contributions by Catherine Devlin, http://catherinedevlin.blogspot.com 21 and sqlpyPlus. Major contributions by Catherine Devlin, http://catherinedevlin.blogspot.com
22
23 Usage: sqlpython [connect string] [single-word command] ["multi-word command"]...
24
22 Quick start command list: 25 Quick start command list:
23 26
24 - top -> executes a query to list all active sessions in (Oracle 10g and RAC) 27 - top -> executes a query to list all active sessions in (Oracle 10g and RAC)
25 (use: instance activity monitoring, a DBA tool) 28 (use: instance activity monitoring, a DBA tool)
26 - tselect -> prints the result set in trasposed form, useful to print result sets with 29 - tselect -> prints the result set in trasposed form, useful to print result sets with
164 my=mysqlpy() 167 my=mysqlpy()
165 print my.__doc__ 168 print my.__doc__
166 try: 169 try:
167 if sys.argv[1][0] != '@': 170 if sys.argv[1][0] != '@':
168 my.do_connect(sys.argv.pop(1)) 171 my.do_connect(sys.argv.pop(1))
169 arg = ' '.join(sys.argv[1:]) 172 for arg in sys.argv[1:]:
170 if my.onecmd(arg): 173 if my.onecmd(arg + ';') == my._STOP_AND_EXIT:
171 return 174 return
172 except IndexError: 175 except IndexError:
173 pass 176 pass
174 my.cmdloop() 177 my.cmdloop()
175 178
176 if __name__ == '__main__': 179 if __name__ == '__main__':