Psycopg 3.3.0.dev1 released - with Template Strings support!
От | Daniele Varrazzo |
---|---|
Тема | Psycopg 3.3.0.dev1 released - with Template Strings support! |
Дата | |
Msg-id | CA+mi_8Y0iOsQWJKMU2B=ek8ETOmAaA+dm5LsSQbLDq4wFWrtOQ@mail.gmail.com обсуждение исходный текст |
Список | 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
В списке psycopg по дате отправления: