Menu

#18 0.39 breaks Connection().execute()

open
nobody
None
5
2008-10-14
2008-10-14
No

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)]]

Discussion

  • Gregory Bond

    Gregory Bond - 2008-10-15

    Patch to restore most of the old execute() behaviour.

     
  • Gregory Bond

    Gregory Bond - 2008-10-15

    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 post a comment.