Share

Sybase module for Python

Tracker: Bugs

5 0.39 breaks Connection().execute() - ID: 2165436
Last Update: Comment added ( gnbond )

All previous versions have supported returning data from the execute()
method of a Connection object. 0.39 breaks this, execute() now returns
None.

e.g.:

db = Sybase.Connect(....)
print db.execute('select 1,2,3')

We use this facility pretty much exclusively in preference to cursors.

The following patch seems to restore at least some backwards-compatible
behaviour for single statements:

$ diff -u Sybase.py.Orig Sybase.py
--- Sybase.py.Orig Mon Apr 14 19:01:59 2008
+++ Sybase.py Tue Oct 14 17:08:32 2008
@@ -1032,7 +1032,13 @@
try:
cursor = self.cursor()
cursor.execute(sql)
+ ret = []
+ while 1:
+ ret.append(cursor.fetchall())
+ if not cursor.nextset():
+ break
cursor.close()
+ return ret
finally:
self._unlock()

but this is not complete.... previous versions permitted (and we used)
multiple selects which would return a set of results, things like

db.execute('Select 1, 2, 3 select 4,5,6')
which would return
[[(1, 2, 3)], [(4, 5, 6)]]



Gregory Bond ( gnbond ) - 2008-10-14 06:14

5

Open

None

Nobody/Anonymous

None

None

Public


Comment ( 1 )




Date: 2008-10-15 00:29
Sender: gnbond

Ignore that patch, it doesn't handle the non-select case "db.execute('use
dbname')" etc.

Attached patch handles all cases correctly except multiple selects - this
patch returns all results in one set, 0.38 returned multiple sets. e.g.
for the above case would return [[(1, 2, 3), (4, 5, 6)]] vs 0.38 [[(1, 2,
3)], [(4, 5, 6)]]


File Added: diffs


Log in to comment.

Attached File ( 1 )

Filename Description Download
diffs Patch to restore _most_ of the old execute() behaviour. Download

Change ( 1 )

Field Old Value Date By
File Added 297399: diffs 2008-10-15 00:29 gnbond