Trying to insert data to a new empty table with unique constraints. When I remove the ON CONFLICT statement the code errors out immediately with a violation of the unique constraint in the first insert try even though the table is empty. When I remove the unique constraints from the table, the data is duplicated when I rerun the code.
I would like the insert to verify if the row exists and do nothing and if it does not exist, to make a new entry. I'm running postgres 11.3 on Mac OSX. Any help appreciated.
psycopg2.extras.execute_values(cur,
"insert into ferc_hots (html,link) values %s",
values)
on conflict (html,link) do nothing
con.commit()
print("Records inserted successfully")
con.close()