Skip to content

ClientCursor: TypeError: not enough arguments for format string #399

@ochedru

Description

@ochedru

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions