[DB-SIG] [ANNOUNCEMENT] MySQLdb-0.1.3 released

M.-A. Lemburg mal@lemburg.com
Thu, 09 Mar 2000 19:04:41 +0100


Andy Dustman wrote:
> 
> On Thu, 9 Mar 2000, M.-A. Lemburg wrote:
> 
> > > What's changed:
> > >
> > > - Core dump on exit under certain conditions (probably only when
> > >   using executeXXX() on dictionaries) seems to be fixed.
> > >
> > > - cursor.fetchXXXDict() methods added for backwards-compatibility with
> > >   MySQLmodule (plus some people think it's cool to have).
> > >
> >
> > Could you elaborate a bit ? What do these methods do and
> > how are dictionaries involved ?
> 
> cursor.fetchrow(), of course, returns the result as a sequence of values,
> usually a tuple. cursor.fetchrowDict() returns the result as a dictionary,
> where the keys are the column names and the values are the column values.

How does this help with columns which are the result of
a SQL function, e.g. select max(value) from table ?

Wouldn't the same functionality be available by simply
merging the information from cursor.description and the
result of .fetchone() (that's how my own abstract DB class works,
BTW) ?
 
> Joe Skinner, original author of MySQLmodule, has since pointed out to me
> that this does not actually provide backwards-compatibility with
> MySQLmodule, since MySQLmodule would set the keys to table.column, to
> guarantee key uniqueness. In these cases, I would say it is best to modify
> the query to use the AS keyword to rename fields, i.e.:
> 
> SELECT t1.name AS name1, t2.name AS name2, t1.id FROM t1, t2
> WHERE t1.id = t2.id;
> 
> (I'm not 100% sure the is the correct syntax, but close enough.)

Should be ok... according to ANSI SQL.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/