Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jS11J-0006wG-CB for pgsql-general@arkaria.postgresql.org; Fri, 24 Apr 2020 16:17:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jS11I-0005Kq-9g for pgsql-general@arkaria.postgresql.org; Fri, 24 Apr 2020 16:17:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jS11H-0005Ki-Up for pgsql-general@lists.postgresql.org; Fri, 24 Apr 2020 16:17:40 +0000 Received: from mail-il1-x141.google.com ([2607:f8b0:4864:20::141]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jS11F-0002FA-9I for pgsql-general@lists.postgresql.org; Fri, 24 Apr 2020 16:17:39 +0000 Received: by mail-il1-x141.google.com with SMTP id e8so9775821ilm.7 for ; Fri, 24 Apr 2020 09:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=NmROPtldaTcyq/re/L3ydjEOQDY8zeaXgc6Mz7dy0q4=; b=a+a+arwY2QuhPj0PhL4KSdf7H6oQoZCVtrrb9UkphvpCk7J5EvH2XGVuwid/ekiFMh /RZJnnINlNq7gU6RKSL0NW5z84QR1eUi45dtTHqftiRhqMVXRkkgEQEg4iqBXnvVFhpZ V0UH/5M6RtRdWTv/buHb5jroVenr5lqxOcOlzxGOK8j4Yr935jsT6fikUdjHur2QoXLj S1oUfzXTZAtgTH0NGN6+sturNFq1ZCQTwJGBaYeagocxfh/UZ1Om0z/PeXFdY6/Eu1if jsslC/gJVQ5CxmpUWHufAOB4qfZ+vImcKazMTOGsNLmhuL3AMSiF0ddh6h3XYMrjWTsX ZXSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=NmROPtldaTcyq/re/L3ydjEOQDY8zeaXgc6Mz7dy0q4=; b=juJDV1nA/9eT9W4VvwBNunVhXJAKREOfCCuBpQNOErSdLWi++UZMaVBUAS+Q7n+OL2 t4W3RlvWXaiCtd5Y85A3Uk70s+zHBLDnkOErVWE+cjIBQdyF//s3ivD708IzJwGq+uZq XxgqAcI0akyCB/JVojQdY0+kNwHc0bVtBQFkg4EumqSj6JQF3b1rrnG5mUlehpCiJZcG SWOEEZ5e8i2w21skXAhQt507SIqm4O2KyIfnD5AylE/yJQo6AZ3UZ+QASfkn3OrXssYm oo7wii4dAhMsOXIGTp8d55dgztkv3cac28LI4mNokmCoFt4k91VZtx1VpRKF7uOIidCS /5Tw== X-Gm-Message-State: AGi0PuZPdXa9098HK0svGksY8B5gpR7aNABOzOZJlFNZC6TNIsgAPVoS t7t4Q4J28j/t8S5Pg6nsrfMHxHZQryo= X-Google-Smtp-Source: APiQypJiqCITQ4XBPS1hmzqTfo4izw8gEWZ7gNf4uCLWYtIEnbzSdaJ24eHo+6/cnL7ReE1Trgh/eA== X-Received: by 2002:a92:d4c4:: with SMTP id o4mr9702123ilm.38.1587745055233; Fri, 24 Apr 2020 09:17:35 -0700 (PDT) Received: from ?IPv6:2601:681:5500:dde0:a5fb:e276:c4c4:17bd? ([2601:681:5500:dde0:a5fb:e276:c4c4:17bd]) by smtp.gmail.com with ESMTPSA id x11sm2215691ilm.64.2020.04.24.09.16.56 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Apr 2020 09:17:09 -0700 (PDT) Subject: Re: psql \copy To: pgsql-general@lists.postgresql.org References: From: Rob Sargent Message-ID: Date: Fri, 24 Apr 2020 10:16:44 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------6B8D2447CC5DBDFA199399FA" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------6B8D2447CC5DBDFA199399FA Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 4/24/20 10: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 >> > 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. > Is the duplication due to overlapping 15min chunks (i.e. imprecise definition of  "15 minutes ago")?  Perhaps retaining last timestamp sent to pg and use in the get-from-influx call? > -- > 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 > > Email Confidentiality Notice: The information contained in this > transmission may contain privileged and confidential and/or protected > health information (PHI) and may be subject to protection under the > law, including the Health Insurance Portability and Accountability Act > of 1996, as amended (HIPAA). This transmission is intended for the > sole use of the individual or entity to whom it is addressed. If you > are not the intended recipient, you are notified that any use, > dissemination, distribution, printing or copying of this transmission > is strictly prohibited and may subject you to criminal or civil > penalties. If you have received this transmission in error, please > contact the sender immediately and delete this email and any > attachments from any computer. Vaso Corporation and its subsidiary > companies are not responsible for data leaks that result from email > messages received that contain privileged and confidential and/or > protected health information (PHI). --------------6B8D2447CC5DBDFA199399FA Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

On 4/24/20 10: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> 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.

Is the duplication due to overlapping 15min chunks (i.e. imprecise definition of  "15 minutes ago")?  Perhaps retaining last timestamp sent to pg and use in the get-from-influx call?

--
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

Email Confidentiality Notice: The information contained in this transmission may contain privileged and confidential and/or protected health information (PHI) and may be subject to protection under the law, including the Health Insurance Portability and Accountability Act of 1996, as amended (HIPAA). This transmission is intended for the sole use of the individual or entity to whom it is addressed. If you are not the intended recipient, you are notified that any use, dissemination, distribution, printing or copying of this transmission is strictly prohibited and may subject you to criminal or civil penalties. If you have received this transmission in error, please contact the sender immediately and delete this email and any attachments from any computer. Vaso Corporation and its subsidiary companies are not responsible for data leaks that result from email messages received that contain privileged and confidential and/or protected health information (PHI).

--------------6B8D2447CC5DBDFA199399FA--