[python-sybase] Patches and maintenance (was Re: This routine cannot be called because another command structure has results pending)

Greg Ward gward-pysybase at python.net
Fri Jul 7 23:33:33 EST 2006


On 07 July 2006, Andrew McNamara said:
> If someone is offering to put pre-release code through it's paces,
> we can do that without SF (yeah, it's a pretty clunky way of doing it,
> but we all did somehow get by before the SF, and even IP connectivity 8-)

I'm willing to test out patches posted to this list.  I only have access
to a 6-year old version of Sybase (11.0.3) though.  I suppose that's
useful for testing compatibility with old versions.

> Obviously Greg's patch should go in - are there any other patches vs
> 0.37 that should be applied? I'll put together a devel snapshot for you
> to download and test, and if all goes well, we'll call that 0.38.

I noticed some copy 'n pasted code, which always rubs me the wrong way;
here's a patch to correct it.  It's running fine on my development
server right now.

        Greg

P.S. patch is relative to my '_close_fetcher()' patch.

P.P.S. I just realized that perhaps I should have called it
'_closefetcher()' for consistency with the rest of the code.  Andrew,
please rename it if you feel that's the right thing to do.  Stylistic
consistency is more important than worrying about hurting some
contributor's feelings!
-------------- next part --------------
--- Sybase.py.1.close-fetcher	2006-07-05 12:49:12.000000000 -0400
+++ Sybase.py	2006-07-07 09:10:29.000000000 -0400
@@ -788,19 +788,13 @@
     def fetchone(self):
         '''DB-API Cursor.fetchone()
         '''
-        if self._closed:
-            raise ProgrammingError('cursor is closed')
-        if not self._fetcher:
-            raise ProgrammingError('query has not been executed')
+        self._checkready()
         return self._fetcher.fetchone()
 
     def fetchmany(self, num = -1):
         '''DB-API Cursor.fetchmany()
         '''
-        if self._closed:
-            raise ProgrammingError('cursor is closed')
-        if not self._fetcher:
-            raise ProgrammingError('query has not been executed')
+        self._checkready()
         if num < 0:
             num = self.arraysize
         return self._fetcher.fetchmany(num)
@@ -808,25 +802,25 @@
     def fetchall(self):
         '''DB-API Cursor.fetchall()
         '''
-        if self._closed:
-            raise ProgrammingError('cursor is closed')
-        if not self._fetcher:
-            raise ProgrammingError('query has not been executed')
+        self._checkready()
         return self._fetcher.fetchall()
 
     def nextset(self):
         '''DB-API Cursor.nextset()
         '''
-        if self._closed:
-            raise ProgrammingError('cursor is closed')
-        if not self._fetcher:
-            raise ProgrammingError('query has not been executed')
+        self._checkready()
         desc = self._fetcher.nextset()
         if desc:
             self.description = desc
             return 1
         return 0
 
+    def _checkready(self):
+        if self._closed:
+            raise ProgrammingError('cursor is closed')
+        if not self._fetcher:
+            raise ProgrammingError('query has not been executed')
+
     def setinputsizes(self, *sizes):
         '''DB-API Cursor.setinputsizes()
         '''


More information about the Python-sybase mailing list