Re: Load data from a csv file without using COPY - Mailing list pgsql-general

From Hans Schou
Subject Re: Load data from a csv file without using COPY
Date
Msg-id CAApBw350wx_a+rBGTw_AioofrCJwHzm5nTAsguJCoCabBP1P=A@mail.gmail.com
Whole thread Raw
In response to Load data from a csv file without using COPY  (Ravi Krishna <srkrishna@yahoo.com>)
List pgsql-general
On Tue, Jun 19, 2018 at 10:17 PM Ravi Krishna <srkrishna@yahoo.com> wrote:
In order to test a real life scenario (and use it for benchmarking) I want to load large number of data from csv files. 
The requirement is that the load should happen like an application writing to the database ( that is, no COPY command). 

Once you have parsed the data it is fairly easy to use PostgreSQL "COPY FROM stdin" format. If you have all data with a tabulator separator. A simple table (t1) could look like:

COPY t1 (f1,f2) FROM stdin;
3<tab>Joe
7<tab>Jane
\.

These data can be piped directly to psql and it will be fast.

Note: NULL should be '\N', see manual:

It is the same kind of data you get with pg_dump.

./hans 

pgsql-general by date:

Previous
From: Nicolas Paris
Date:
Subject: Re: Load data from a csv file without using COPY
Next
From: "David G. Johnston"
Date:
Subject: Re: Load data from a csv file without using COPY