pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Steve Clark <steve.clark@netwolves.com>
To: pgsql <pgsql-general@postgresql.org>
Subject: Re: psql \copy
Date: Fri, 24 Apr 2020 09:15:52 -0700
Message-ID: <fd8c16f9-9fd3-a7ad-d718-04048d84b448@aklaver.com> (raw)
In-Reply-To: <b1b63be6-1571-cbbb-ff8c-d577103a0b2c@netwolves.com>
References: <b1ad085a-6fb0-979d-3d7a-01ce52e61e53@netwolves.com>
	<CAEfWYyyZQMxWak8WRXZWZ8jZ5+x9QJPvDD5EYGFtrVvFnD4U1Q@mail.gmail.com>
	<b1b63be6-1571-cbbb-ff8c-d577103a0b2c@netwolves.com>

On 4/24/20 9:12 AM, Steve Clark wrote:
> On 04/24/2020 11:59 AM, Steve Crawford wrote:
>> On Fri, Apr 24, 2020 at 8:55 AM Steve Clark <steve.clark@netwolves.com 
>> <mailto:steve.clark@netwolves.com>> wrote:
>>
>>     Hello,
>>
>>     I am using psql to copy data extracted from an InfluxDB in csv
>>     format into postgresql.
>>     I have a key field on the time field which I have defined as a
>>     bigint since the time I get
>>     from InfluxDB is an epoch time.
>>
>>     My question is does psql abort the copy if it hits a duplicate
>>     key, or does it keep processing?
>>
>>
>> The copy will fail. You could import into a temporary table and 
>> preprocess then copy to your permanent table or use an ETL solution to 
>> remove unwanted data before importing. I don't know the nature of your 
>> data or project but perhaps that column isn't suitable for a key.
>>
>> Cheers,
>> Steve
> I am attempting to periodically pull time series data from an InfluxDB.
> The column at issue is the timestamp. I have a script that pulls the 
> last 15 minutes of data from the InfluxDB
> as csv data and pipe it into a psql -c "\copy...." command. I was 
> looking for the simplest way to do this.

Then as suggested above pull into staging table that has no constraints 
e.g. PK. Verify data and then push into permanent table.

> 
> -- 
> Stephen Clark
> *NetWolves Managed Services, LLC.*
> Sr. Applications Architect
> Phone: 813-579-3200
> Fax: 813-882-0209
> Email: steve.clark@netwolves.com
> http://www.netwolves.com


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (12+ messages)  latest in thread

Message-ID: <fd8c16f9-9fd3-a7ad-d718-04048d84b448@aklaver.com>
Permalink:  ../fd8c16f9-9fd3-a7ad-d718-04048d84b448@aklaver.com/
Also on:    postgresql.org/message-id/fd8c16f9-9fd3-a7ad-d718-04048d84b448@aklaver.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-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, steve.clark@netwolves.com
  Subject: Re: psql \copy
  In-Reply-To: <fd8c16f9-9fd3-a7ad-d718-04048d84b448@aklaver.com>
  References: <b1ad085a-6fb0-979d-3d7a-01ce52e61e53@netwolves.com> <CAEfWYyyZQMxWak8WRXZWZ8jZ5+x9QJPvDD5EYGFtrVvFnD4U1Q@mail.gmail.com> <b1b63be6-1571-cbbb-ff8c-d577103a0b2c@netwolves.com> <fd8c16f9-9fd3-a7ad-d718-04048d84b448@aklaver.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