How can I pass a list to an IN statement in a query using psycopg's named arguments?
Example:
cur.execute("""
SELECT name
FROM users
WHERE id IN (%(ids)s)
""",
{"ids": [1, 2, 3]})
When I do that, I get the following error message:
psycopg.errors.UndefinedFunction: operator does not exist: integer = smallint[]
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
... WHERE id = ANY(%(ids)s)""", {"ids": [1, 2, 3]}
per List adaption. – Holdup