Bug in PostgreSQL/Python (7.1.1/1.5) fetchone()

Поиск
Список
Период
Сортировка
От Kevin Cole
Тема Bug in PostgreSQL/Python (7.1.1/1.5) fetchone()
Дата
Msg-id Pine.LNX.4.33.0106042229580.30316-100000@gri.gallaudet.edu
обсуждение исходный текст
Список 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@dustman.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@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

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Michael Nguyen
Дата:
Сообщение: column check constraint
Следующее
От: kyle
Дата:
Сообщение: where clause bug