pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Vladimir Yevdokimov <vladimir@givex.com>
To: David.Bear@asu.edu
Cc: pgsql-admin@postgresql.org
Subject: Re: psql copy errors
Date: Thu, 23 Jun 2005 17:48:19 -0400
Message-ID: <200506231748.19051.vladimir@givex.com> (raw)
In-Reply-To: <20050623192744.GC398@asu.edu>
References: <20050623192744.GC398@asu.edu>

On June 23, 2005 03:27 pm, David Bear wrote:
> I'm finding the \copy is very brittle. It seems to stop for everyone
> little reason. Is there a way to tell it to be more forgiving -- for
> example, to ignore extra data fields that might exists on a line?
> 
> Or, to have it just skip that offending record but continue on to the
> next.
> 
> I've got a tab delimited file, but if \copy sees any extra tabs in the
> file it just stops at that record. I want to be able to control what
> pg does when it hits an exception.
> 
> I'm curious what others do for bulk data migration. Since copy seems
> so brittle, there must be a better way...
> 

You may use '-d' option of pg_dump in which case it dumps data into INSERT statements.
In this case when you load the damped data it will process tabs properly and will fail any invalid records but finish the process itself.
If you redirect output into a separate file you can analyze later how many records failed.
May be that's what you need in your case.
The only problem with this method I know is that it takes longer to load the data as it does full validation for each record.
-- 
Vladimir Yevdokimov <vladimir@givex.com>



view thread (6+ messages)  latest in thread

Message-ID: <200506231748.19051.vladimir@givex.com>
Permalink:  ../200506231748.19051.vladimir@givex.com/
Also on:    postgresql.org/message-id/200506231748.19051.vladimir@givex.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: vladimir@givex.com, David.Bear@asu.edu
  Subject: Re: psql copy errors
  In-Reply-To: <200506231748.19051.vladimir@givex.com>
  References: <20050623192744.GC398@asu.edu> <200506231748.19051.vladimir@givex.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox