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

From Daniele Varrazzo
Subject Re: Best strategy for bulk inserts where some violate unique constraint?
Date
Msg-id CA+mi_8Z4y4L=xNC_xnmiELPnJ4tdp4QXUbEDogr71whyVL0XsQ@mail.gmail.com
Whole thread Raw
In response to Re: Best strategy for bulk inserts where some violate unique constraint?  (Adrian Klaver <adrian.klaver@gmail.com>)
Responses Re: Best strategy for bulk inserts where some violate unique constraint?
List psycopg
On Wed, Nov 6, 2013 at 2:54 PM, Adrian Klaver <adrian.klaver@gmail.com> wrote:
> On 11/06/2013 06:50 AM, Denis Papathanasiou wrote:
>>
>> On Tue, Nov 5, 2013 at 6:31 PM, Daniele Varrazzo
>>
>> I saw Adrian's reply about how this still won't do what I need in terms
>> of ignoring the constraint violators and keeping the valid entries; will
>> switching autocommit to True first have the desired effect?
>
> No, a particular COPY is treated as a single transaction.

If I'm not mistaken, copying into a temporary table and then inserting
only the wanted record into the target table should work as expected
and leave no bloat. Staying into the psycopg realm it should be the
most efficient way to load data; outside psycopg world there could be
more efficient stand-alone solutions.

-- Daniele


psycopg by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Best strategy for bulk inserts where some violate unique constraint?
Next
From: Adrian Klaver
Date:
Subject: Re: Best strategy for bulk inserts where some violate unique constraint?