Best strategy for bulk inserts where some violate unique constraint? - Mailing list psycopg

From Denis Papathanasiou
Subject Best strategy for bulk inserts where some violate unique constraint?
Date
Msg-id CAEpnaGzfZ2kZgAx72xi6SwN1sfx8xb42VaFdh__9siPuQtAw5w@mail.gmail.com
Whole thread Raw
Responses Re: Best strategy for bulk inserts where some violate unique constraint?
List psycopg
I'm using Pyscopg2 to insert multiple rows at once, using a dictionary as shown at the bottom of this page: https://wiki.postgresql.org/wiki/Psycopg2_Tutorial

I notice that even if just one entry violates a table unique constraint (an IntegrityError in psycopg2 parlance), the entire contents of the dictionary do not get inserted into the table.

Is there any way to tell postgres: it's ok to reject individual entries that may violate table unique constraints, but at the same time allow those which do not?

It's too expensive for me to do the inserts one at a time where I could just catch the psycopg2.IntegrityError.

psycopg by date:

Previous
From: Damiano Albani
Date:
Subject: Re: Understanding memory usage
Next
From: Daniele Varrazzo
Date:
Subject: Re: Best strategy for bulk inserts where some violate unique constraint?