comparison mysqlpy.py @ 103:4aa28dffe658 1.4.6

command-line args working well
author catherine@localhost
date Thu, 29 May 2008 14:20:55 -0400
parents 9c5371b5edf4
children 58d15cb69f72
comparison
equal deleted inserted replaced
102:c5f601abc993 103:4aa28dffe658
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # MySqlPy V1.3 2 # MySqlPy V1.4.6
3 # Author: Luca.Canali@cern.ch 3 # Author: Luca.Canali@cern.ch
4 # 4 #
5 # 5 #
6 # Companion of SqlPython, a python module that reproduces Oracle's command line within python 6 # Companion of SqlPython, a python module that reproduces Oracle's command line within python
7 # 'sqlplus inside python' 7 # 'sqlplus inside python'
11 from sqlpyPlus import * 11 from sqlpyPlus import *
12 import binascii, sys, tempfile 12 import binascii, sys, tempfile
13 13
14 class mysqlpy(sqlpyPlus): 14 class mysqlpy(sqlpyPlus):
15 ''' 15 '''
16 MySqlPy V1.3 - 'sqlplus in python' 16 MySqlPy V1.4.6 - 'sqlplus in python'
17 Author: Luca.Canali@cern.ch 17 Author: Luca.Canali@cern.ch
18 Rev: 1.4.4, 28-May-08 18 Rev: 1.4.8, 29-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 22
23 Usage: sqlpython [connect string] [single-word command] ["multi-word command"]... 23 Usage: sqlpython [connect string] [single-word command] ["multi-word command"]...
166 def run(): 166 def run():
167 my=mysqlpy() 167 my=mysqlpy()
168 print my.__doc__ 168 print my.__doc__
169 try: 169 try:
170 if sys.argv[1][0] != '@': 170 if sys.argv[1][0] != '@':
171 my.do_connect(sys.argv.pop(1)) 171 connectstring = sys.argv.pop(1)
172 try: # attach AS SYSDBA or AS SYSOPER if present
173 for connectmode in my.connection_modes.keys():
174 if connectmode.search(' %s %s' % tuple(sys.argv[1:3])):
175 for i in (1,2):
176 connectstring += ' ' + sys.argv.pop(1)
177 break
178 except TypeError:
179 pass
180 my.do_connect(connectstring)
172 for arg in sys.argv[1:]: 181 for arg in sys.argv[1:]:
173 if my.onecmd(arg, assumeComplete=True) == my._STOP_AND_EXIT: # ugh, filename gets ; appended 182 if my.onecmd(arg, assumeComplete=True) == my._STOP_AND_EXIT:
174 return 183 return
175 except IndexError: 184 except IndexError:
176 pass 185 pass
177 my.cmdloop() 186 my.cmdloop()
178 187