Re: iterating over DictRow - Mailing list psycopg

From Adrian Klaver
Subject Re: iterating over DictRow
Date
Msg-id 7b2272a8-de4d-bc95-1efc-84d69ea7c4c1@aklaver.com
Whole thread Raw
In response to RE: iterating over DictRow  (David Raymond <David.Raymond@tomtom.com>)
List psycopg
On 9/24/20 7:53 AM, 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
thinkwhat it "should" be is a little ambiguous. But you can always either cast it to a dict, or iterate over .keys() if
youwant the field names.
 
> 
> for field in dict(the_dict):
>      ...
> or
> for field in the_dict.keys():
>     ...
> 

Except I think the_dict is actually the_list. I was just about to post a 
reply to my post saying that my use of the_dict was incorrect as I was 
actually iterating over a list.

-- 
Adrian Klaver
adrian.klaver@aklaver.com



psycopg by date:

Previous
From: David Raymond
Date:
Subject: RE: iterating over DictRow
Next
From: Karsten Hilbert
Date:
Subject: Re: iterating over DictRow