MySQL adapter question
Steve Holden
sholden at holdenweb.com
Tue Sep 12 09:34:54 EDT 2000
FAQTS (http://python.faqts.com) is one quite good place for Python
code snippets. I suspect thare are others as well.
regards
Steve
Pop Tufty wrote:
>
> Jeff,
>
> Thanks, that did the trick. I am glad that
> that this is a great news group. Is there a place I can
> go to find code snippets such as this? Seems like there
> should be a spot I could grep for said snippets.
>
> thanks again - pop
>
> Jeff Bauer wrote:
>
> > 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?
--
Helping people meet their information needs with training and technology.
703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/
More information about the Python-list
mailing list