I am currently in the process of converting a large code base from psycopg2 to psycopg3.
Please consider the following code snippet, tested with psycopg 3.1.2:
from psycopg import connect, ClientCursor
with connect('host=locahost user=postgres password=postgres', cursor_factory=ClientCursor) as con:
with con.cursor() as cur:
cur.execute("SELECT format('%%s', %(param)s)", {'param': 'test'})
print(cur.fetchone()[0])
With psycopg2, the result is test but psycopg3 raises the following error:
TypeError: not enough arguments for format string
Is this a bug or did I overlook a new way to escape percent signs? Thanks!