| From: | Ams Fwd <ams(dot)fwd(at)gmail(dot)com> |
|---|---|
| To: | Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com> |
| Cc: | psycopg(at)postgresql(dot)org |
| Subject: | Re: 2-to-3 Question about adapter using AsIs |
| Date: | 2023-11-21 01:24:32 |
| Message-ID: | CAP80KYroXEQYZ7x+xVPT1RTGV8H7ESra4KRdY7Lz4wM6vRLMCw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | psycopg |
Hi.
On Mon, Nov 20, 2023 at 2:46 PM Daniele Varrazzo
<daniele(dot)varrazzo(at)gmail(dot)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')"
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Daniele Varrazzo | 2024-01-07 16:09:55 | New releases, and happy new year! |
| Previous Message | Daniele Varrazzo | 2023-11-20 22:46:21 | Re: 2-to-3 Question about adapter using AsIs |