From: | Kevin Cole <kjcole(at)gri(dot)gallaudet(dot)edu> |
---|---|
To: | <db-sig(at)python(dot)org>, <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Bug in PostgreSQL/Python (7.1.1/1.5) fetchone() |
Date: | 2001-06-05 02:46:17 |
Message-ID: | Pine.LNX.4.33.0106042229580.30316-100000@gri.gallaudet.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Hi again,
It appears that the bug in pgdb occurs for both examples below. Both
return the first row multiple times. (This is with PostgreSQL 7.1.1
and Python 1.5.2.)
_________________________________________
for hits in range(curse.rowcount):
print curse.fetchone()
_________________________________________
row = curse.fetchone()
while row:
print row
row = curse.fetchone()
_________________________________________
On Mon, 4 Jun 2001, Andy Dustman <andy(at)dustman(dot)net> wrote:
>On Fri, 1 Jun 2001, Kevin Cole wrote:
> > 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?
> Nothing that I can see. Each fetchone() invocation should return a new
> row, so this sounds like a pgdb bug. I wouldn't use range(curse.rowcount)
> myself; more likely I'd use fetchall(). If the result set can be
> arbitrarily large, I'd do something like this:
>
> row = curse.fetchone()
> while row:
> print row
> row = curse.fetchone()
>
> --
> Andy Dustman PGP: 0xC72F3F1D
> @ .net http://dustman.net/andy
--
Kevin Cole | E-mail: kjcole(at)gri(dot)gallaudet(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Trurl McByte | 2001-06-05 14:39:28 | |
Previous Message | Michael Caine | 2001-06-04 15:57:33 | Re(2): REFERENCES fails on derived classes |