Select as dictionary...

Bruno Desthuilliers bruno.42.desthuilliers at wtf.websiteburo.oops.com
Mon Oct 1 11:13:29 EDT 2007


J. Clifford Dyer a écrit :
> On Mon, Oct 01, 2007 at 03:50:59PM +0200, Bruno Desthuilliers wrote regarding Re: Select as dictionary...:
>> IIRC, postgres' db-api connector (well, at least one of them - I don't 
>> know which one you're using) has a DictCursor. You should find all you 
>> want to know in the relevant doc.
>>
> 
> Correct me if I'm wrong, but I think the DictCursor would output the following:
> 
> [{'id': 1, 'value': 5}, {'id': 2, 'value': 5}, ...]
> 
> But the OP wanted one dict with IDs as keys:
> 
> {1: 5, 2: 5, ...}

Hmmm... I did answer too fast, indeed. Thanks for pointing that out.




More information about the Python-list mailing list