pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedpsql \copy
12+ messages / 8 participants
[nested] [flat]
* psql \copy
@ 2019-06-04 08:50 paul.malm@lfv.se
2019-06-04 08:59 ` Re: psql \copy Pavel Stehule <pavel.stehule@gmail.com>
0 siblings, 1 reply; 12+ messages in thread
From: paul.malm@lfv.se @ 2019-06-04 08:50 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi. I'm trying to execute this command:
C:\P_bin\psql -h 10.233.37.24 -p 5432 -U tester -d test -w -c "\copy public.BadenWuerttemberg_20181011 FROM C:\data\Baden-Wuerttemberg.csv' WITH DELIMITER ';' CSV"
Error: relation "public.badenwuerttemberg_20181011" does not exist.
What am I Doing wrong?
There is a table (badenwuerttemberg_20181011) in database test under the public schema. The table has all the columns, with the right types, as the csv-file.
I'm using PostgreSQL 11
Kind regards,
Paul
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: psql \copy
2019-06-04 08:50 psql \copy paul.malm@lfv.se
@ 2019-06-04 08:59 ` Pavel Stehule <pavel.stehule@gmail.com>
2019-06-04 17:18 ` Re: psql \copy paul.malm@lfv.se
0 siblings, 1 reply; 12+ messages in thread
From: Pavel Stehule @ 2019-06-04 08:59 UTC (permalink / raw)
To: paul.malm@lfv.se; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Hi
út 4. 6. 2019 v 10:50 odesílatel <paul.malm@lfv.se> napsal:
> Hi. I’m trying to execute this command:
>
> C:\P_bin\psql -h 10.233.37.24 -p 5432 -U tester -d test -w -c "\copy
> public.BadenWuerttemberg_20181011 FROM C:\data\Baden-Wuerttemberg.csv' WITH
> DELIMITER ';' CSV"
>
> Error: relation "public.badenwuerttemberg_20181011" does not exist.
>
> What am I Doing wrong?
>
looks like case sensitive identifier is used. try
"\copy public.""BadenWuerttemberg_20181011"" ...
Regards
Pavel Stehule
>
> There is a table (badenwuerttemberg_20181011) in database test under the
> public schema. The table has all the columns, with the right types, as the
> csv-file.
>
> I’m using PostgreSQL 11
>
> Kind regards,
>
> Paul
>
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: psql \copy
2019-06-04 08:50 psql \copy paul.malm@lfv.se
2019-06-04 08:59 ` Re: psql \copy Pavel Stehule <pavel.stehule@gmail.com>
@ 2019-06-04 17:18 ` paul.malm@lfv.se
0 siblings, 0 replies; 12+ messages in thread
From: paul.malm@lfv.se @ 2019-06-04 17:18 UTC (permalink / raw)
To: pavel.stehule@gmail.com; +Cc: pgsql-general@lists.postgresql.org
Thanx, it worked! :)
4 juni 2019 kl. 11:00 skrev Pavel Stehule <pavel.stehule@gmail.com<mailto:pavel.stehule@gmail.com>>:
Hi
út 4. 6. 2019 v 10:50 odesílatel <paul.malm@lfv.se<mailto:paul.malm@lfv.se>> napsal:
Hi. I’m trying to execute this command:
C:\P_bin\psql -h 10.233.37.24 -p 5432 -U tester -d test -w -c "\copy public.BadenWuerttemberg_20181011 FROM C:\data\Baden-Wuerttemberg.csv' WITH DELIMITER ';' CSV"
Error: relation "public.badenwuerttemberg_20181011" does not exist.
What am I Doing wrong?
looks like case sensitive identifier is used. try
"\copy public.""BadenWuerttemberg_20181011"" ...
Regards
Pavel Stehule
There is a table (badenwuerttemberg_20181011) in database test under the public schema. The table has all the columns, with the right types, as the csv-file.
I’m using PostgreSQL 11
Kind regards,
Paul
^ permalink raw reply [nested|flat] 12+ messages in thread
* psql \copy
@ 2020-04-24 15:55 Steve Clark <steve.clark@netwolves.com>
2020-04-24 15:59 ` Re: psql \copy Adrian Klaver <adrian.klaver@aklaver.com>
2020-04-24 15:59 ` Re: psql \copy David G. Johnston <david.g.johnston@gmail.com>
2020-04-24 15:59 ` Re: psql \copy Steve Crawford <scrawford@pinpointresearch.com>
2020-04-24 16:36 ` Re: psql \copy Ron <ronljohnsonjr@gmail.com>
0 siblings, 4 replies; 12+ messages in thread
From: Steve Clark @ 2020-04-24 15:55 UTC (permalink / raw)
To: pgsql-general
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?
Thanks,
--
Stephen Clark
NetWolves Managed Services, LLC.
Sr. Applications Architect
Phone: 813-579-3200
Fax: 813-882-0209
Email: steve.clark@netwolves.com<mailto: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).
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: psql \copy
2020-04-24 15:55 psql \copy Steve Clark <steve.clark@netwolves.com>
@ 2020-04-24 15:59 ` Adrian Klaver <adrian.klaver@aklaver.com>
3 siblings, 0 replies; 12+ messages in thread
From: Adrian Klaver @ 2020-04-24 15:59 UTC (permalink / raw)
To: Steve Clark <steve.clark@netwolves.com>; pgsql-general
On 4/24/20 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?
Aborts.
\copy uses COPY so:
https://www.postgresql.org/docs/12/sql-copy.html
"COPY stops operation at the first error. This should not lead to
problems in the event of a COPY TO, but the target table will already
have received earlier rows in a COPY FROM. These rows will not be
visible or accessible, but they still occupy disk space. This might
amount to a considerable amount of wasted disk space if the failure
happened well into a large copy operation. You might wish to invoke
VACUUM to recover the wasted space."
>
>
> Thanks,
> --
> 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).
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: psql \copy
2020-04-24 15:55 psql \copy Steve Clark <steve.clark@netwolves.com>
@ 2020-04-24 15:59 ` David G. Johnston <david.g.johnston@gmail.com>
3 siblings, 0 replies; 12+ messages in thread
From: David G. Johnston @ 2020-04-24 15:59 UTC (permalink / raw)
To: Steve Clark <steve.clark@netwolves.com>; +Cc: pgsql-general
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?
>
>
Aborts
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: psql \copy
2020-04-24 15:55 psql \copy Steve Clark <steve.clark@netwolves.com>
@ 2020-04-24 15:59 ` Steve Crawford <scrawford@pinpointresearch.com>
2020-04-24 16:12 ` Re: psql \copy Steve Clark <steve.clark@netwolves.com>
3 siblings, 1 reply; 12+ messages in thread
From: Steve Crawford @ 2020-04-24 15:59 UTC (permalink / raw)
To: Steve Clark <steve.clark@netwolves.com>; +Cc: pgsql-general
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
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: psql \copy
2020-04-24 15:55 psql \copy Steve Clark <steve.clark@netwolves.com>
2020-04-24 15:59 ` Re: psql \copy Steve Crawford <scrawford@pinpointresearch.com>
@ 2020-04-24 16:12 ` Steve Clark <steve.clark@netwolves.com>
2020-04-24 16:15 ` Re: psql \copy Adrian Klaver <adrian.klaver@aklaver.com>
2020-04-24 16:16 ` Re: psql \copy Rob Sargent <robjsargent@gmail.com>
0 siblings, 2 replies; 12+ messages in thread
From: Steve Clark @ 2020-04-24 16:12 UTC (permalink / raw)
To: pgsql-general
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.
--
Stephen Clark
NetWolves Managed Services, LLC.
Sr. Applications Architect
Phone: 813-579-3200
Fax: 813-882-0209
Email: steve.clark@netwolves.com<mailto: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).
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: psql \copy
2020-04-24 15:55 psql \copy Steve Clark <steve.clark@netwolves.com>
2020-04-24 15:59 ` Re: psql \copy Steve Crawford <scrawford@pinpointresearch.com>
2020-04-24 16:12 ` Re: psql \copy Steve Clark <steve.clark@netwolves.com>
@ 2020-04-24 16:15 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-04-24 16:19 ` Re: psql \copy Steve Clark <steve.clark@netwolves.com>
1 sibling, 1 reply; 12+ messages in thread
From: Adrian Klaver @ 2020-04-24 16:15 UTC (permalink / raw)
To: Steve Clark <steve.clark@netwolves.com>; pgsql-general
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
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: psql \copy
2020-04-24 15:55 psql \copy Steve Clark <steve.clark@netwolves.com>
2020-04-24 15:59 ` Re: psql \copy Steve Crawford <scrawford@pinpointresearch.com>
2020-04-24 16:12 ` Re: psql \copy Steve Clark <steve.clark@netwolves.com>
2020-04-24 16:15 ` Re: psql \copy Adrian Klaver <adrian.klaver@aklaver.com>
@ 2020-04-24 16:19 ` Steve Clark <steve.clark@netwolves.com>
0 siblings, 0 replies; 12+ messages in thread
From: Steve Clark @ 2020-04-24 16:19 UTC (permalink / raw)
To: pgsql-general
On 04/24/2020 12:15 PM, Adrian Klaver wrote:
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>
<mailto: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.
Thanks for the tip. I'll head down that road. Stay safe everyone.
--
Stephen Clark
*NetWolves Managed Services, LLC.*
Sr. Applications Architect
Phone: 813-579-3200
Fax: 813-882-0209
Email: steve.clark@netwolves.com<mailto:steve.clark@netwolves.com>
http://www.netwolves.com
--
Stephen Clark
NetWolves Managed Services, LLC.
Sr. Applications Architect
Phone: 813-579-3200
Fax: 813-882-0209
Email: steve.clark@netwolves.com<mailto: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).
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: psql \copy
2020-04-24 15:55 psql \copy Steve Clark <steve.clark@netwolves.com>
2020-04-24 15:59 ` Re: psql \copy Steve Crawford <scrawford@pinpointresearch.com>
2020-04-24 16:12 ` Re: psql \copy Steve Clark <steve.clark@netwolves.com>
@ 2020-04-24 16:16 ` Rob Sargent <robjsargent@gmail.com>
1 sibling, 0 replies; 12+ messages in thread
From: Rob Sargent @ 2020-04-24 16:16 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
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 <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.
>
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).
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: psql \copy
2020-04-24 15:55 psql \copy Steve Clark <steve.clark@netwolves.com>
@ 2020-04-24 16:36 ` Ron <ronljohnsonjr@gmail.com>
3 siblings, 0 replies; 12+ messages in thread
From: Ron @ 2020-04-24 16:36 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
You might want to investigate pg_bulkload for this activity.
On 4/24/20 10: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?
>
--
Angular momentum makes the world go 'round.
^ permalink raw reply [nested|flat] 12+ messages in thread
end of thread, other threads:[~2020-04-24 16:36 UTC | newest]
Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-06-04 08:50 psql \copy paul.malm@lfv.se
2019-06-04 08:59 ` Pavel Stehule <pavel.stehule@gmail.com>
2019-06-04 17:18 ` paul.malm@lfv.se
2020-04-24 15:55 psql \copy Steve Clark <steve.clark@netwolves.com>
2020-04-24 15:59 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-04-24 15:59 ` David G. Johnston <david.g.johnston@gmail.com>
2020-04-24 15:59 ` Steve Crawford <scrawford@pinpointresearch.com>
2020-04-24 16:12 ` Steve Clark <steve.clark@netwolves.com>
2020-04-24 16:15 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-04-24 16:19 ` Steve Clark <steve.clark@netwolves.com>
2020-04-24 16:16 ` Rob Sargent <robjsargent@gmail.com>
2020-04-24 16:36 ` Ron <ronljohnsonjr@gmail.com>
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