Bug 1 Final Fix: - Changed all placeholders from $1, $2, $3 to %s - psycopg2 expects Python-style %s, converts to $N internally - Using $N directly causes 'there is no parameter $1' error - Removed param_idx counter (not needed with %s) Root cause: Mixing PostgreSQL native syntax with psycopg2 driver This is THE fix that will finally work!