public inbox for [email protected]
help / color / mirror / Atom feedFrom: Daniel Fortunov <[email protected]>
To: Denis Laxalde <[email protected]>
Cc: Daniele Varrazzo <[email protected]>
Cc: [email protected]
Subject: Re: Latest developments in psycopg3
Date: Mon, 8 Feb 2021 22:38:10 +0000
Message-ID: <CAH1rg6b41jgi2A7qOaUGx1KwkuzD3hNMFWwfcQPKb1Oy5FGVRQ@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CA+mi_8btbC_-0KheQ3WYZW81fS4B0MyPyuALihmqHTvqq=6VyA@mail.gmail.com>
<[email protected]>
<CA+mi_8YZnEuO=GAJiWnv_0Bx7_6DsL9jUcwhMxtXGqeSBgSp0A@mail.gmail.com>
<[email protected]>
>
> > 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.
view thread (10+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Latest developments in psycopg3
In-Reply-To: <CAH1rg6b41jgi2A7qOaUGx1KwkuzD3hNMFWwfcQPKb1Oy5FGVRQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox