Re: 2-to-3 Question about adapter using AsIs - Mailing list psycopg

From Ams Fwd
Subject Re: 2-to-3 Question about adapter using AsIs
Date
Msg-id CAP80KYroXEQYZ7x+xVPT1RTGV8H7ESra4KRdY7Lz4wM6vRLMCw@mail.gmail.com
Whole thread Raw
In response to Re: 2-to-3 Question about adapter using AsIs  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
List psycopg
Hi.

On Mon, Nov 20, 2023 at 2:46 PM Daniele Varrazzo
<daniele.varrazzo@gmail.com> wrote:

So it turns out that the Django default, at least for 4.2 is ClientCursors :)

https://docs.djangoproject.com/en/4.2/ref/databases/#server-side-parameters-binding

Which means I can get the `quote` based solution work ootb.

Thanks a ton for the clarification.
AM

> but you can only use `PostgresDefaultValueType` with a ClientCursor
> (or in a `sql.Literal()`); you can visualize the query that a client
> cursor would execute using the classic `mogrify()`:
>
>     >>> cur = psycopg.ClientCursor(conn)
>     >>> cur.mogrify("INSERT INTO tbl (f1, f2) VALUES (%s, %s)",
> [PostgresDefaultValueType(), "hell'o"])
>     "INSERT INTO tbl (f1, f2) VALUES (DEFAULT, 'hell''o')"
>



psycopg by date:

Previous
From: Daniele Varrazzo
Date:
Subject: Re: 2-to-3 Question about adapter using AsIs
Next
From: Daniele Varrazzo
Date:
Subject: New releases, and happy new year!