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 1u8TMt-004p2l-Rb for psycopg@arkaria.postgresql.org; Sat, 26 Apr 2025 00:26:08 +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 1u8TMq-00GiHg-EH for psycopg@arkaria.postgresql.org; Sat, 26 Apr 2025 00:26:05 +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 1u8TMq-00GiHY-7p for psycopg@lists.postgresql.org; Sat, 26 Apr 2025 00:26:05 +0000 Received: from mail-yb1-xb31.google.com ([2607:f8b0:4864:20::b31]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u8TMn-0025pa-1l for psycopg@postgresql.org; Sat, 26 Apr 2025 00:26:04 +0000 Received: by mail-yb1-xb31.google.com with SMTP id 3f1490d57ef6-e730ea57804so1785107276.1 for ; Fri, 25 Apr 2025 17:26:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745627159; x=1746231959; darn=postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=xYb5K3VOMciAi0T/Vk06KUfYKDghZK2HurApnyzLO/U=; b=fq9WP1/3WbpxM6sZRBdBuqYu7gDSHOPVgvfmscZ3QCqiF6h2cVD5ls5OQJ6hEu4EKe sJpfzjtZbHQzDlSTnha7tzuoYE6xktGVsCUt2qCDmFsH2l47JSdSrMCdwTTqu5en1ZPQ U4hIx9EfTP1qQhltlXoI8TVHQSil7VoohoZhTMYUm9ySR7d2oBGb+IF6vFsPtXQwGncw 2MVp72ZkkAX4UzbEufgAiV1utaHDRGRDNapiABZ3tFbb5P/xYvBp9Rf1mYk7Kx3UJl0l SerDUoEDgi10UJDzO4E7xJ1RPIqUzekoemkDLjIgROAGmfMRW1xkypvZw1T+Wki/Y0QJ k/TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745627159; x=1746231959; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=xYb5K3VOMciAi0T/Vk06KUfYKDghZK2HurApnyzLO/U=; b=nTj8FSppEUYGwQcb86c7BjI/CLR2ijuFscNGaXZ5yfz8zmGmlzJGCLbL3eEbubqor0 4xBR8iSJ2NAJkC3vh9IWa82S7ZWti7jmqiTBeniKYcShB2p7tEgfmXyCyMmdW02TTh/Z CeUEbXans32yZJz84kl2AgHuVbjSwKgwqFifZEBCJZhRQn8JducsdqQ+WdKA7z+fgt5n utMDBTqocURBYxwpghDmXXdHJoHCvOST54TeQ4pKFpx3n4JGzk+q5nbLoOuaLQhqVdSJ LY3OjcXpPSCWpRzrC+djemJjL3ibE65fY0JoD4k0wJbiFi1Gc8v372sjCQR2emFrkHyx fFfg== X-Gm-Message-State: AOJu0YyeBUdl/m4oExBLev/PSz4aS79nbPXUQoBGH/eB1Im4BZvF8GcO lgSG1eE0U72VXd0UM5x3DYuNt3YieiWQSswYovS3Yek/n99vyZPwx3FePcKRuR/E3YktlNGvlRw 5IiNnCVMqC877T38og40lkhMLU//d7JH5 X-Gm-Gg: ASbGncszrl6dwtNabBkLA7UX8ZC7Ra9XiHjAh/dsV9XjfCpk9Y5gwe34i6Ns7OGpjIF 3zldYebSAe6eaSygjPvHKVaatwdjtYtFOzrTezV4NhZwRgFfU7LOhJ+G3OsD4GcaAAXPPiC21MA bl9c9VUbP5/RWgyDBxoEdH X-Google-Smtp-Source: AGHT+IHRqKm7pu0/2mZszcQCCEj2OPAMzLUhQ5ktrkwJSVZi7YcZdsR0q6TNuJ4cb1Ymc/hwW54XsYhtl+W9tVotf5k= X-Received: by 2002:a05:6902:2381:b0:e69:18e6:6729 with SMTP id 3f1490d57ef6-e731718b555mr5592104276.13.1745627159039; Fri, 25 Apr 2025 17:25:59 -0700 (PDT) MIME-Version: 1.0 From: Daniele Varrazzo Date: Sat, 26 Apr 2025 02:25:47 +0200 X-Gm-Features: ATxdqUFvTtMCb3msUXmxv7Y_yhBEIRZpZOdfYRrjb1aekVGqq7rrqtst3R0BfNM Message-ID: Subject: Python 3.14, template-strings, and psycopg To: Psycopg Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello, Python 3.14, scheduled for release in October, introduces Template Strings (https://peps.python.org/pep-0750/), which might be useful to compose query parameters in a very elegant way, while ensuring safety: value = 42 cur.execute(t"select * from mytable where id = {value}") I have started to think about a few details about the feature, such as whether to allow non-values parts of the query too in the parameters, for example allowing to use: value = 42 table_name = sql.Identifier("mytable") cur.execute(t"select * from {table_name} where id = {value}") to which we would merge the table name client-side and the value server-side. I have written some thoughts in . if anyone would like to express their opinion about the design of this feature, you are very welcome. Thank you very much! -- Daniele