Ed Leafe wrote:
On Monday 15 August 2005 04:10, Adi J. Sieker wrote:


I  worked a little bit on it this morning in the train.
cur.description is not of type list when the result set is empty.


 That's not good!


When I try add the method massageDescription to dbSQLite
and do this:
   if c.description == None: c.description = []

I get a read-only attribute exception. So I'm a little
bit at a loss on where to go from here.


Me too. I suppose we could work around it by using something other than the direct cursor property (such as a custom Dabo property), but that would take a bit of reworking of the whole db module. Paul, any ideas?


Also how to best handle this situation or is it even needed?
From the pysqlite documentation:
1. Python Database API 2.0 Compliance
1.1 Incompatibilities

No type information in cursor.description


Not too critical. We currently only use the field names, since the type descriptions are a series of codes instead of direct type info. But it is odd that it doesn't return an empty list in the description when there is no data.

So, let me get this straight:

If there is data returned, cursor.description is a list of the field names, but not of types. If there is no data returned, cursor.description is None.

If the above is true, and if it is also true that Dabo only uses the field names anyway, then it seems that a simple defensive block like this would suffice:

cursorDescription = cursor.description
if not isinstance(cursorDescription, list, tuple):
        cursorDescription = []
# and from then on, refer to cursorDescription instead of directly
# to cursor.description


--
Paul McNett
http://paulmcnett.com


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Reply via email to