diff sqlpython.py @ 80:83de0cb04f12

prevent crash on lone backslash
author catherine@localhost
date Wed, 14 May 2008 17:23:52 -0400
parents d0bf9e40ba8d
children fa8c9eb8908f
line wrap: on
line diff
--- a/sqlpython.py	Mon Apr 28 12:20:53 2008 -0400
+++ b/sqlpython.py	Wed May 14 17:23:52 2008 -0400
@@ -9,7 +9,7 @@
 # See also http://twiki.cern.ch/twiki/bin/view/PSSGroup/SqlPython
 
 import cmd2,getpass,binascii,cx_Oracle,re
-import pexpecter
+import pexpecter, sqlpyPlus
     
     # complication! separate sessions ->
     # separate transactions !!!!!
@@ -102,7 +102,8 @@
     def default(self, arg, do_everywhere = False):
         self.query = self.finishStatement(arg).strip().rstrip(';')
         try:
-            self.curs.execute(self.query)
+            self.varsUsed = sqlpyPlus.findBinds(self.query, self.binds, givenBindVars={})
+            self.curs.execute(self.query, self.varsUsed)            
             print '\nExecuted%s\n' % ((self.curs.rowcount > 0) and ' (%d rows)' % self.curs.rowcount or '')
             if do_everywhere:
                 self.fail(arg, do_everywhere = True )
@@ -140,7 +141,7 @@
         mustsplit = 0             # flag 
         for j in rcols:
             if str(desc[j][1]) == "<type 'cx_Oracle.BINARY'>":  # handles RAW columns
-                 rowsi[j] = binascii.b2a_hex(rowsi[j])
+                rowsi[j] = binascii.b2a_hex(rowsi[j])
             maxen[j] = max(maxen[j], len(rowsi[j]))    # computes max field length
             if maxen[j] <= maxlen:
                 split.append('')