Re: Iterating through cur and cur.fetchone()

Поиск
Список
Период
Сортировка
От Håvard Wahl Kongsgård
Тема Re: Iterating through cur and cur.fetchone()
Дата
Msg-id CAKH910-YZ_XZLAcbwSd=T5907dXbJHf9XoUGAZYEUxbR4h2w-Q@mail.gmail.com
обсуждение исходный текст
Ответ на Iterating through cur and cur.fetchone()  (Håvard Wahl Kongsgård <haavard.kongsgaard@gmail.com>)
Ответы Re: Iterating through cur and cur.fetchone()  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
Список psycopg
Sorry, I stupid mistake. But I have been using psycopg for a year and
I have some issue with memory usage on large cursors.
Any tips on how to reduce the memory usage.

-Håvard

2011/10/10 Håvard Wahl Kongsgård <haavard.kongsgaard@gmail.com>:
> Hi, how do I use cur.fetchone() when iterating through a cur object.
>
> with
> conn = psycopg2.connect()
> cur = conn.cursor()
> SQL = ('select * from something limit 1000')
>
> n = 1
> cur.execute(SQL)
> for edge_list in cur:
>    edge = cur.fetchone()
>    print n
>
>    n = n +1
>
> I get
> n = 500
>
> when I skip edge = cur.fetchone()
>
> for edge_list in cur:
>    print n
>
>    n = n +1
>
> n = 1000
>
> Why does this happen, and what is the solution?
>
>
> --
> Håvard Wahl Kongsgård
>

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

Предыдущее
От: Daniele Varrazzo
Дата:
Сообщение: Re: Iterating through cur and cur.fetchone()
Следующее
От: Daniele Varrazzo
Дата:
Сообщение: Re: Iterating through cur and cur.fetchone()