changeset 2:59903dcaf327

working on history
author devlinjs@FA7CZA6N1254998.wrightpatterson.afmc.ds.af.mil
date Mon, 03 Dec 2007 14:29:16 -0500
parents 8fa146b9a2d7
children cd23cd62de3c
files sqlpyPlus.py sqlpython.py
diffstat 2 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpyPlus.py	Fri Nov 30 16:44:26 2007 -0500
+++ b/sqlpyPlus.py	Mon Dec 03 14:29:16 2007 -0500
@@ -272,7 +272,8 @@
         self.spoolFile = None
         self.autobind = False
         self.failover = False
-        self.singleline = '''desc describe'''.split()
+        self.singleline = '''select insert update delete
+        create drop alter'''.split()
 
     def default(self, arg, do_everywhere=False):
         sqlpython.sqlpython.default(self, arg, do_everywhere)
@@ -324,9 +325,9 @@
         try:
             args = line.split(None,1)
             args[0] = args[0].lower()
-            statement = ' '.join(args)            
-            if args[0] not in self.singleline:
-                statement = finishStatement(statement)
+            statement = ' '.join(args)      
+            if args[0] in self.singleline:
+                statement = sqlpython.finishStatement(statement)
             return statement
         except Exception:
             return line
@@ -371,8 +372,6 @@
     def output_as_html_table(self):
         result = ''.join('<th>%s</th>' % c for c in self.colnames)
         result = ['  <tr>\n    %s\n  </tr>' % result]
-        print result
-        print type(result)
         for row in self.rows:
             result.append('  <tr>\n    %s\n  </tr>' %
                           (''.join('<td>%s</td>' %
@@ -440,11 +439,11 @@
             try:
                 self.varsUsed = findBinds(self.query, self.binds, bindVarsIn)
                 self.curs.execute(self.query, self.varsUsed)
-                self.rows = self.curs.fetchmany(min(self.maxfetch, (stmt.rowlimit or self.maxfetch)))
+                self.rows = self.curs.fetchmany(min(self.maxfetch, (rowlimit or self.maxfetch)))
                 self.desc = self.curs.description
                 self.rc = self.curs.rowcount
                 if self.rc > 0:
-                    print '\n' + self.output(outformat, rowlimit)
+                    print '\n' + self.output(terminator, rowlimit)
                 if self.rc == 0:
                     print '\nNo rows Selected.\n'
                 elif self.rc == 1: 
--- a/sqlpython.py	Fri Nov 30 16:44:26 2007 -0500
+++ b/sqlpython.py	Mon Dec 03 14:29:16 2007 -0500
@@ -100,7 +100,7 @@
     do_sen = do_senora       
         
     def default(self, arg, do_everywhere = False):
-        self.query = Statement(arg).query
+        self.query = finishStatement(arg)
         try:
             self.curs.execute(self.query)
             print '\nExecuted\n'
@@ -120,7 +120,7 @@
     do_q = do_quit
     do_exit = do_quit
 
-stmtEndSearchString = r'(.*)(%s)\s*(\d+)?\s*$' % terminatorSearchString
+stmtEndSearchString = r'(.*)(%s)\s*(\d+)?\s*$' % sqlpython.terminatorSearchString
 stmtEndFinder = re.compile(stmtEndSearchString, re.MULTILINE | re.DOTALL)
 prompt2 = ' > '