Best strategy for bulk inserts where some violate unique constraint?

Поиск
Список
Период
Сортировка
От Denis Papathanasiou
Тема Best strategy for bulk inserts where some violate unique constraint?
Дата
Msg-id CAEpnaGzfZ2kZgAx72xi6SwN1sfx8xb42VaFdh__9siPuQtAw5w@mail.gmail.com
обсуждение исходный текст
Ответы Re: Best strategy for bulk inserts where some violate unique constraint?  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Damiano Albani
Дата:
Сообщение: Re: Understanding memory usage
Следующее
От: Daniele Varrazzo
Дата:
Сообщение: Re: Best strategy for bulk inserts where some violate unique constraint?