Re: How to generate file from postgres data

From: Vijaykumar Jain <vijaykumarjain(dot)github(at)gmail(dot)com>
To: Shubham Mittal <mittalshubham30(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: How to generate file from postgres data
Date: 2021-06-12 11:53:36
Message-ID: CAM+6J94y2NXiRC-zKbS8asTPcQ7CbDeJ_BtfpM_wS8V1m0D+TQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

test=# create table t(id int, value text);
CREATE TABLE
test=# insert into t select x, x::text from generate_series(1, 1000) x;
INSERT 0 1000
test=# COPY (select * from t where id < 50 order by id desc) TO
'/tmp/report.csv' DELIMITER ',' CSV HEADER; ---- copy out the results via
a view or sql directly
COPY 49
test=# \q
postgres(at)db:~/playground$ head -5 /tmp/report.csv
id,value
49,49
48,48
47,47
46,46

and send the csv tar zip compressed etc.

How does your client intend to load 1gb report in a viewer ? paginated ?
all at once ?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vijaykumar Jain 2021-06-12 11:57:55 Re: How to generate file from postgres data
Previous Message Shubham Mittal 2021-06-12 11:35:24 How to generate file from postgres data