changeset 340:001d01eeac90

bind vars for postgres
author Catherine Devlin <catherine.devlin@gmail.com>
date Thu, 09 Apr 2009 15:54:08 -0400
parents 545f63b6ef42
children aa16fe026f01 09bb5789e72d
files setup.py sqlpython/sqlpyPlus.py sqlpython/sqlpython.py
diffstat 3 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Thu Apr 09 14:42:41 2009 -0400
+++ b/setup.py	Thu Apr 09 15:54:08 2009 -0400
@@ -17,7 +17,7 @@
       url="http://packages.python.org/sqlpython",
       packages=find_packages(),
       include_package_data=True,    
-      install_requires=['pyparsing','cmd2>=0.5.2','cx_Oracle','genshi>=0.5','sqlalchemy'],
+      install_requires=['pyparsing','cmd2>=0.5.2','cx_Oracle','genshi>=0.5','sqlalchemy','gerald'],
       keywords = 'client oracle database',
       license = 'MIT',
       platforms = ['any'],
--- a/sqlpython/sqlpyPlus.py	Thu Apr 09 14:42:41 2009 -0400
+++ b/sqlpython/sqlpyPlus.py	Thu Apr 09 15:54:08 2009 -0400
@@ -655,7 +655,7 @@
             self.perror("Specify desired number of rows after terminator (not '%s')" % arg.parsed.suffix)
         if arg.parsed.terminator == '\\t':
             rowlimit = rowlimit or self.maxtselctrows
-        self.varsUsed = self.findBinds(arg, self.binds, bindVarsIn)
+        self.varsUsed = self.findBinds(arg, bindVarsIn)
         if self.wildsql:
             selecttext = self.expandWildSql(arg)
         else:
@@ -1233,7 +1233,7 @@
         if arg.startswith(':'):
             self.do_setbind(arg[1:])
         else:
-            varsUsed = self.findBinds(arg, self.binds, {})
+            varsUsed = self.findBinds(arg, {})
             try:
                 self.curs.execute('begin\n%s;end;' % arg, varsUsed)
             except Exception, e:
--- a/sqlpython/sqlpython.py	Thu Apr 09 14:42:41 2009 -0400
+++ b/sqlpython/sqlpython.py	Thu Apr 09 15:54:08 2009 -0400
@@ -274,20 +274,20 @@
     bindScanner = {'oracle': Parser(pyparsing.Literal(':') + pyparsing.Word( pyparsing.alphanums + "_$#" )),
                    'postgres': Parser(pyparsing.Literal('%(') + 
                                       pyparsing.Word(pyparsing.alphanums + "_$#") + ')s')}
-    def findBinds(self, target, existingBinds, givenBindVars = {}):
+    def findBinds(self, target, givenBindVars = {}):
         result = givenBindVars
         if self.rdbms in self.bindScanner:
             for finding, startat, endat in self.bindScanner[self.rdbms].scanner.scanString(target):
                 varname = finding[1]
                 try:
-                    result[varname] = existingBinds[varname]
+                    result[varname] = self.binds[varname]
                 except KeyError:
                     if not givenBindVars.has_key(varname):
                         print 'Bind variable %s not defined.' % (varname)
         return result
 
     def default(self, arg):
-        self.varsUsed = self.findBinds(arg, self.binds, givenBindVars={})
+        self.varsUsed = self.findBinds(arg, givenBindVars={})
         ending_args = arg.lower().split()[-2:]
         if 'end' in ending_args:
             command = '%s %s;'