Is it possible to retrieve the information for whether an upsert inserted a new value or updated an old one? Specifically I want to try to retrieve the id of the new inserted row if an insert occurred, or None if no insert occurred.
If it's helpful, I'm using python's psycog2 to interact with Postgres.
My Upsert looks somewhat like this:
INSERT INTO user (user_id, name, date, phone) VALUES (%(user_id)s,%(name)s, %(date)s, %(phone)s) ON CONFLICT (user_id, name) DO NOTHING
EDIT: I've seen returning, but it's unclear whether this would work as intended with upsert. example here:
INSERT INTO persons (lastname,firstname) VALUES ('Smith', 'John') RETURNING id;
Any help would be appreciated!