MySQL adapter question

Jeff Bauer jbauer at rubic.com
Mon Sep 11 21:08:40 EDT 2000


Pop,

You're using an older MySQL interface.  You might want
to check Andy Dustman's version, since it is better
supported.

  http://dustman.net/andy/python/

Anyhow, here's some (untested) code using the old 
interface:

    STH = DBH.query("select Measurement from tablea")
    fields = map(lambda x: x[0], STH.fields())
    for row in STH.fetchrows():
        for i in range(len(fields)):
            print "field %s is %s" % (fields[i], row[i])
        print  # print blank line separator


Regards,

Jeff Bauer
Rubicon Research


Pop Tufty wrote:
> DBH = MySQL.connect() # localhost
> DBH.selectdb("mydb")
> STH = DBH.query("select Measurement from tablea")
> for i in STH.fetchrows():
>     print "field data is "
>     print STH.data[i]
> 
> The STH.data[i] line does not work.  What do
> I put there to iterate along the values returned from
> the query?




More information about the Python-list mailing list