diff 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
line wrap: on
line diff
--- a/mysqlpy.py	Thu May 29 13:14:06 2008 -0400
+++ b/mysqlpy.py	Thu May 29 14:20:55 2008 -0400
@@ -1,5 +1,5 @@
 #!/usr/bin/python
-# MySqlPy V1.3
+# MySqlPy V1.4.6
 # Author: Luca.Canali@cern.ch
 # 
 #
@@ -13,9 +13,9 @@
 
 class mysqlpy(sqlpyPlus):
     '''
-MySqlPy V1.3 - 'sqlplus in python'
+MySqlPy V1.4.6 - 'sqlplus in python'
 Author: Luca.Canali@cern.ch
-Rev: 1.4.4, 28-May-08
+Rev: 1.4.8, 29-May-08
 
 Companion of SqlPython, a python module that reproduces Oracle's command line within python
 and sqlpyPlus. Major contributions by Catherine Devlin, http://catherinedevlin.blogspot.com
@@ -168,9 +168,18 @@
     print my.__doc__
     try:
         if sys.argv[1][0] != '@':
-            my.do_connect(sys.argv.pop(1))
+            connectstring = sys.argv.pop(1)
+            try:   # attach AS SYSDBA or AS SYSOPER if present
+                for connectmode in my.connection_modes.keys():
+                    if connectmode.search(' %s %s' % tuple(sys.argv[1:3])):
+                        for i in (1,2):
+                            connectstring += ' ' + sys.argv.pop(1)
+                        break
+            except TypeError:
+                pass
+            my.do_connect(connectstring)
         for arg in sys.argv[1:]:
-            if my.onecmd(arg, assumeComplete=True) == my._STOP_AND_EXIT:  # ugh, filename gets ; appended 
+            if my.onecmd(arg, assumeComplete=True) == my._STOP_AND_EXIT:
                 return
     except IndexError:
         pass