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

From David G. Johnston
Subject Re: Load data from a csv file without using COPY
Date
Msg-id CAKFQuwYhfbUqbevbgv=nT2HmOeeAcncUwZ=YWdyF8Y3+Nz9f_w@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 1:16 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).
Is there a tool which can do the job.  Basically parse the csv file and insert it to the database row by row.

​I'm skeptical that injesting CSV of any form, even if you intentionally blow things up by converting into:

BEGIN;
INSERT INTO tbl VALUES ('','','');
COMMIT;
BEGIN;
INSERT INTO tbl VALUES ('','','');
COMMIT;

(which is what auto-commit mode looks like)

Is going to provide a meaningful ​benchmark for application-like usage patterns.

But anyway, I'm not familiar with any tools that make doing this particularly simple.  In most situations like this I'll just import the CSV into a spreadsheet and create a formula that builds out the individual SQL commands.  Whether that's useful depends a lot on how often the source CSV is updated.

That said, I have the following tool to be generally helpful in this area - though I'm thinking it doesn't do what you want here.


David J.

pgsql-general by date:

Previous
From: Hans Schou
Date:
Subject: Re: Load data from a csv file without using COPY
Next
From: Alban Hertroys
Date:
Subject: Re: Is postorder tree traversal possible with recursive CTE's?