Re: Latest developments in psycopg3 - Mailing list psycopg

From Daniel Fortunov
Subject Re: Latest developments in psycopg3
Date
Msg-id CAH1rg6b41jgi2A7qOaUGx1KwkuzD3hNMFWwfcQPKb1Oy5FGVRQ@mail.gmail.com
Whole thread Raw
In response to Re: Latest developments in psycopg3  (Denis Laxalde <denis.laxalde@dalibo.com>)
List psycopg
> 1) We can provide a feature to select the type of cursor that is not
> much dissimilar from psycopg2
> 2) Do we need DictCursor/RealDictCursor? ISTM that one of the two
> would be sufficient? Possibly an object inheriting from a Python dict
> instead of emulating it so that e.g. json.dumps()

Inheriting from dict is strange because we only need read access. So
rather collections.abc.Mapping, I think.
 
One advantage of using a real dict is that it leaves the door open for the caller to mutate the results as they consume them. A little impure, I know, but one practical example I can think of would be where you want to augment your results with additional data (coming from a different source, outside the database).

RealDictCursor gives you the flexibility to do this, whereas collections.abc.Mapping would force you to construct a new dict instance for every row in order to get the same result.

psycopg by date:

Previous
From: Rory Campbell-Lange
Date:
Subject: Re: Latest developments in psycopg3
Next
From: Daniele Varrazzo
Date:
Subject: Re: about client-side cursors