Iterating through cur and cur.fetchone() - Mailing list psycopg

From Håvard Wahl Kongsgård
Subject Iterating through cur and cur.fetchone()
Date
Msg-id CAKH9109mY1c=wzdBuV24wMDPXM+94vJzUcPZ404EF6BzgYt_AA@mail.gmail.com
Whole thread Raw
Responses Re: Iterating through cur and cur.fetchone()  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
Re: Iterating through cur and cur.fetchone()  (Håvard Wahl Kongsgård <haavard.kongsgaard@gmail.com>)
List psycopg
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 by date:

Previous
From: Daniele Varrazzo
Date:
Subject: Re: 2.4.2: undefined symbol: lo_truncate
Next
From: Daniele Varrazzo
Date:
Subject: Re: Iterating through cur and cur.fetchone()