[DB-SIG] Newbie trying to fetch individual rows w/ PostgreSQL

Kevin Cole kjcole@gri.gallaudet.edu
Fri, 1 Jun 2001 14:00:43 -0400 (EDT)


Hi,

I've got a little test code that sorta works, but not as well as I'd
like.  fetchall() does what I want, fetchone() appears to fetch the same
row cursor.rowcount times, rather than fetching the next row.  Here's
what I'm doing:

    import pgdb
    mydb = pgdb.connect("localhost:mydb")
    curse = mydb.cursor()
    curse.execute("select * from mytable where state = 'MD')
    for hits in range(curse.rowcount):
       print curse.fetchone()

If I use "for hits in curse.fetchall():" I get what I expect, and
printing curse.rowcount yields the correct number of rows.  What am I
misunderstanding?

-- 
 Kevin Cole, RHCE, Linux Admin  |  E-mail:  kjcole@gri.gallaudet.edu
 Gallaudet Research Institute   |  WWW:     http://gri.gallaudet.edu/~kjcole/
 Hall Memorial Bldg  S-419      |  Voice:   (202) 651-5135
 Washington, D.C.  20002-3695   |  FAX:     (202) 651-5746