[DB-SIG] Use of record sets

Dittmar, Daniel daniel.dittmar@sap.com
Wed, 4 Apr 2001 20:43:48 +0200


 
> > There is one annoying property of SQL in this context: identifier are
> > converted to uppercase unless quoted. Should the UserDict mimic this
> > behaviour by trying both the actual string and the uppercase version?
> 
> This is highly dependent on the native module used to connect to the DB.
> For example, I have found that MySQL preserves column names including 
> upper and lower case letter. However, PostgreSQL disallows the use of
>  upper case letters for column names. I am not exactly sure what the 
> best policy would be, but I personally favor good documentation of 
> the code side effects as opposed the
> any logic that attempts to make the best guess.

The rule should probably be that you can use those strings as keys that you
used in the SQL SELECT list. When the database converts identifier to upper
case, the driver should
- try for an exact match (because you can have lower case identifier if
properly quoted)
- convert string to upper case and try this

> > print "Found id '%s', first name '%s' and last name '%s'"%( result.id,
> > result.first_name, result.last_name)
>
> Yes, this is a problem if you attempt to bind the row data to the
> working namespace. I have not had a need to do so and as a result 
> have been lucky to avoid such problems. Good observation. Any 
> possible solution?

If the column name isn't a valid Python identifier, then you can always
revert to getattr () or using dictionary access.

Daniel

--
Daniel Dittmar
daniel.dittmar@sap.com
SAP DB, SAP Labs Berlin
http://www.sapdb.org/