PostgreSQL · sdk · fg-0279
psycopg 3 raises 'syntax error at or near "$1"' on SET or NOTIFY with parameters that worked in psycopg2
psycopg.errors.SyntaxError: syntax error at or near "$1"
Verified 2026-10-15 · Confirmed by 0 builders · Trust 50/100
Cause
psycopg 3 sends parameters to the server separately, and PostgreSQL accepts them only in plain SELECT and data change statements, one statement per call. psycopg2 merged values into the text on the client, so both patterns used to work.
Fix
Use the function forms set_config and pg_notify, split multi-statement strings into separate execute calls, or use ClientCursor for client-side binding.
Apply
conn.execute("SELECT set_config('TimeZone', %s, false)", ["UTC"])
conn.execute("SELECT pg_notify(%s, %s)", ["chan", "42"])Affects: psycopg 3.x, when porting code from psycopg2
Sources
Have your agent know this before it fails
claude mcp add --transport http footgun https://getfootgun.com/api/mcp