Re: iterating over DictRow - Mailing list psycopg

From Karsten Hilbert
Subject Re: iterating over DictRow
Date
Msg-id 20200924211147.GA2089@hermes.hilbert.loc
Whole thread Raw
In response to RE: iterating over DictRow  (David Raymond <David.Raymond@tomtom.com>)
Responses Re: iterating over DictRow
List psycopg
On Thu, Sep 24, 2020 at 02:53:40PM +0000, David Raymond wrote:

> Since DictRow's can be indexed by either the field name or
> the field index (either record["ID"] or record[0]) then I
> think what it "should" be is a little ambiguous.

I eventually thought so. I was, however, wondering whether I
should have _expected_ iteration over a DictRow to be a list
iteration.

Either of those

> for field in dict(the_dict):
> for field in the_dict.keys():

work, however (or RealDictCursor, for that matter).

Thanks all,
Karsten
--
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B



psycopg by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: iterating over DictRow
Next
From: Adrian Klaver
Date:
Subject: Re: iterating over DictRow