Re: Latest developments in psycopg3
От | Daniel Fortunov |
---|---|
Тема | Re: Latest developments in psycopg3 |
Дата | |
Msg-id | CAH1rg6b41jgi2A7qOaUGx1KwkuzD3hNMFWwfcQPKb1Oy5FGVRQ@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Latest developments in psycopg3 (Denis Laxalde <denis.laxalde@dalibo.com>) |
Список | 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 по дате отправления: