Psycopg 3.3.0.dev1 released - with Template Strings support!

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Psycopg <psycopg(at)postgresql(dot)org>
Subject: Psycopg 3.3.0.dev1 released - with Template Strings support!
Date: 2025-09-09 07:52:47
Message-ID: CA+mi_8Y0iOsQWJKMU2B=ek8ETOmAaA+dm5LsSQbLDq4wFWrtOQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: psycopg

Hello,

I have released a preview version of Psycopg 3.3.0 on test pypi. You
can install it using:

pip install -i https://test.pypi.org/simple/ "psycopg[binary]==3.3.0.dev1"

This version allows writing queries as template strings, a new
language feature released with Python 3.14. The use of t-string in
Psycopg is documented at
<https://www.psycopg.org/psycopg3/docs/basic/tstrings.html>.

Template strings allow to express parametrized queries using the same
syntax of f-strings, but allowing Psycopg to manage the arguments,
either for server-side or for client-side binding - easily both at the
same time. For example a query like the following will have the table
name merged on the client and the id parameter sent separately,
eventually even after the statement is prepared internally:

cursor.execute(t"SELECT * FROM {table_name:i} WHERE id = {id}")

Using t-strings eliminates the need to keep lists of query
placeholders and parameters in sync, making queries easier to read and
to maintain.

I am really excited about this new language feature and I hope that
the support we designed for Psycopg will make the most of it!
Therefore we are releasing preview packages to allow wider testing and
gather feedback before a final 3.3 release.

Feedback is very welcome. Happy hacking!

-- Daniele

Browse psycopg by date

  From Date Subject
Next Message Christophe Pettus 2025-11-16 16:56:07 Overriding default adapters in psycopg
Previous Message Daniele Varrazzo 2025-09-08 10:34:36 Psycopg 3.2.10 released