Re: Query ID Values - Mailing list pgsql-general

From Ian Zimmerman
Subject Re: Query ID Values
Date
Msg-id 20180515050412.s6qmx4yahzp25vgh@matica.foolinux.mooo.com
Whole thread Raw
In response to Re: Query ID Values  (Adrian Klaver <adrian.klaver@aklaver.com>)
Responses Re: Query ID Values
Re: Query ID Values
List pgsql-general
On 2018-05-14 21:12, Adrian Klaver wrote:

> Because you are doing fetchall(). That is going to fetch a list of row
> tuples.  Either iterate over that list or iterate over the cursor:
> 
> for row in cur_p:
>     print(row)
> 
> For more info see:
> http://initd.org/psycopg/docs/cursor.html

Where does that webpage say that I can use the cursor itself for
iteration?  I can't find it there.  (OTOH it is clearly documented for
the sqlite3 library).

Until now, with psycopg2 I have done it like this:

cur.execute(stmt)
results = iter(cur.fetchone, None)
for r in results:
    ...

-- 
Please don't Cc: me privately on mailing lists and Usenet,
if you also post the followup to the list or newsgroup.
To reply privately _only_ on Usenet and on broken lists
which rewrite From, fetch the TXT record for no-use.mooo.com.


pgsql-general by date:

Previous
From: tango ward
Date:
Subject: Re: Query ID Values
Next
From: tango ward
Date:
Subject: Re: Query ID Values