public inbox for [email protected]
help / color / mirror / Atom feedFrom: Vladimir Ryabtsev <[email protected]>
To: Federico Di Gregorio <[email protected]>
Cc: [email protected]
Subject: Re: psycopg3 and adaptation choices
Date: Mon, 9 Nov 2020 17:06:13 -0800
Message-ID: <CAMqTPqkac5xa=+kwKLj8DEr9OdrkJpEzJj4Re8VvKP=JeTdZog@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CA+mi_8Zdk_beGcbOjkpdo+fchTR5ot1XM2zZc=ujSGqP+WVh-g@mail.gmail.com>
<[email protected]>
<CA+mi_8ZfV+rEDKaqM-pcSf43FuN4FUJGoGTxvEEXap-x_GWP0Q@mail.gmail.com>
<[email protected]>
<CA+mi_8YUEPfTPqD-1Jxm6NUwgJpWxPgejRZ+2-mPQr=0DQWiHA@mail.gmail.com>
<[email protected]>
<CA+mi_8a+Q0C2LwiedwNkRPVY=-G3q0zW6w19zYvvADtdEd4b_w@mail.gmail.com>
<[email protected]>
> I wouldn't want to step away from the %s placeholder ...
Thanks for the elaboration, I agree with your argumentation.
> If there is interest we can think about how to make this querying layer
> more accessible (e.g. using a `cur.execute(PgQuery("select $1, $2"),
[...])`
It's always good if such customization is accessible. Having said that,
I can't think of a really good example that benefits from that rather than
from standard use, but basically the more possibilities the better.
> In psycopg3 I've made it slightly easier to use by letting
> `SQL.format()` to accept any Python object
Great, thanks!
May I ask you again about using 'unknown' for numbers? Could you recap
all the downsides of this approach?
Vladimir
On Mon, 9 Nov 2020 at 04:05, Federico Di Gregorio <[email protected]> wrote:
> On 09/11/20 13:00, Daniele Varrazzo wrote:
> > On Mon, 9 Nov 2020 at 06:57, Federico Di Gregorio <[email protected]> wrote:
> [snip]
> >> IMHO, oid is a bad idea
> >> because it has a very specific semantic and the error messages generated
> >> by PostgreSQL will be more confusing.
> >
> > I'm not sure I understand this. At the moment, the oids are something
> > that don't really surface to the end-users, who are not required to
> > use them explicitly and shouldn't be seen in the error messages. For
> > instance the query above might results in a call:
> >
> > >>> from psycopg3.oids import builtins
> > >>> builtins["numeric"].oid
> > 1700
> >
> > >>> res = conn.pgconn.exec_params(b"select '[]'::jsonb -> $1",
> > [b"1"], [1700])
> > >>> res.status
> > <ExecStatus.FATAL_ERROR: 7>
> >
> > >>> print(res.error_message.decode("utf8"))
> > ERROR: operator does not exist: jsonb -> numeric
> > LINE 1: select '[]'::jsonb -> $1
> > ^
> > HINT: No operator matches the given name and argument types. You
> > might need to add explicit type casts.
> >
> > So the oid is only used internally, in the mapping python type ->
> > exec_params() types array, the 1700 shouldn't surface anywhere.
> >
> > Maybe I'm misunderstanding your concern: can you tell me better?
>
> My fault. I misread and though you wanted to use OID as *the* type to
> pass to PostggreSQL for numbers.
>
> federico
>
>
>
>
view thread (23+ messages) latest in thread
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: psycopg3 and adaptation choices
In-Reply-To: <CAMqTPqkac5xa=+kwKLj8DEr9OdrkJpEzJj4Re8VvKP=JeTdZog@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