I need to upsert my pairs table using a with ins statement from python. I am gettin the error: psycopg2.errors.UndefinedTable: missing FROM-clause entry for table "ins" LINE 1: ... pairs_dup_key DO UPDATE SET exchange_pair_symbol=ins.exchan...
This is the sql code that I am running
WITH ins (a, b, c) AS
(VALUES ('sdf',2,3))
INSERT INTO pairs
(foo_id,v,w)
SELECT foo.id, ins.b, ins.c
FROM
ins
LEFT JOIN foo ON foo.name=ins.a
ON CONFLICT ON CONSTRAINT pairs_key DO UPDATE SET v=ins.b, w=ins.c;
What am I doing wrong?