Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r5FVX-00CaBp-6M for psycopg@arkaria.postgresql.org; Tue, 21 Nov 2023 01:24:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r5FVU-00BwXz-T8 for psycopg@arkaria.postgresql.org; Tue, 21 Nov 2023 01:24:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r5FVU-00BwXr-LA for psycopg@lists.postgresql.org; Tue, 21 Nov 2023 01:24:52 +0000 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1r5FVN-007WRR-F3 for psycopg@postgresql.org; Tue, 21 Nov 2023 01:24:51 +0000 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2c871d566cfso36851611fa.3 for ; Mon, 20 Nov 2023 17:24:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700529884; x=1701134684; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xGqEqS8mulYHMqjOgAQmCtcZLOV9yPLn57PWAP49c1g=; b=glOVPs8UgkMMqTLTA6kRfJTn4ao8ruiFhmge7bKsF41SNJMyMs4Y93S5i3q/7P2yGs 47S8DCTjZ+Op83FkzjwaFDRSeddrdDGNeo7ehDF8FgBie58de8iZGcBWXLu9YL746aJ8 +mL5bbWejhuvfqfgRCtzz/RoLxVOjR5PA0h84RgaPnXDIIRAoXfA5w713CRCxP5Z1BBy LaiklugwLFjXsQh1uS6ERb3umQ+TpNb+L/M2KlPTF+C7TO70WIzf1GSc8kfQAaqSOiJF KgunHoJItytJvet5oCTJZ3SotFj8+MgX4pkawdZozWRLXSo6u+giICZSfOTA7eTvFpa1 8Rjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700529884; x=1701134684; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xGqEqS8mulYHMqjOgAQmCtcZLOV9yPLn57PWAP49c1g=; b=HrCDv9iPhxdGQqCcoyxXbVRDBwCHBEgDws4bdz42zcaLZiyZG9gAJlziRCxQpE3ZYS tsXmF1WOvrSeztLrVvXpCCt1a3AdaoEKnguHNYPRmqkNKUTx6OC08+xDgbiLGiRTwUJe KEJzI02koSahIy6ril+iBB0X27MikgL2B1IG63cw4AnAtovBLPmpC3hZRgydjYcU2aAZ BSp7wdMx8X7ulxvmu0sCYa1uVvGvhmbyjLWXzIS8ine3IkwZY493z72FHizXbEnuYlMI p8HG+8/hqPsQ7cNW0lbv77bU8MN7yFTx3DF7gu6rMciV9aaIEzbipqXqfrCRue/Q1MYg 1Gsg== X-Gm-Message-State: AOJu0Yxda0zciC98HoFkl5QNCD6n8syjlmlJxtZd8zohjLZZqT/0jqMI xyOeR6ORXfPcvkhCTcP539IHGRKStWb2z2jTEDg= X-Google-Smtp-Source: AGHT+IHr812rHoImb/fRrYl6lai1VPZ4w5DRBvQbGdWQMk3Zii7/Aqy29ffCTtr+3pAEY4lNZ8RNNsos5yztyLYH1fU= X-Received: by 2002:a2e:9d88:0:b0:2c6:ebfb:dd28 with SMTP id c8-20020a2e9d88000000b002c6ebfbdd28mr5603517ljj.0.1700529884117; Mon, 20 Nov 2023 17:24:44 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Ams Fwd Date: Mon, 20 Nov 2023 17:24:32 -0800 Message-ID: Subject: Re: 2-to-3 Question about adapter using AsIs To: Daniele Varrazzo Cc: psycopg@postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi. On Mon, Nov 20, 2023 at 2:46=E2=80=AFPM Daniele Varrazzo 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 =3D 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')" >