From: | Pierre Chevalier Géologue <pierrechevaliergeol(at)free(dot)fr> |
---|---|
To: | "Ferrell, Denise D CTR NSWCDD, H11" <denise(dot)ferrell(dot)ctr(at)navy(dot)mil>, "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: Extracting data into .csv format |
Date: | 2016-02-18 10:49:19 |
Message-ID: | 56C5A1AF.5070106@free.fr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Hi,
Le 17/02/2016 17:49, Ferrell, Denise D CTR NSWCDD, H11 a écrit :
> Using PostgreSQL 9.3 on Linux
>
> I'm trying to extract data into a comma delimited format and not having
>much success...seems to act totally different from Oracle. Does anyone
>have any suggestions?
Just in case it helps you, I wrote a pair of very simple scripts, but
they have eased my life a lot:
* sql2csv:
https://github.com/pierrechtux/geolllibre/blob/master/sql2csv
sql2csv takes an SQL query as an argument, and spits out the result in
CSV. Just redirecting its output (>) makes a .csv file.
It is extremely trivial: just this is relevant:
echo "COPY ($1) TO stdout WITH CSV HEADER FORCE QUOTE *" | psql -X -h
$GLL_BD_HOST $GLL_BD_NAME
* csv2sql:
https://github.com/pierrechtux/geolllibre/blob/master/csv2sql
csv2sql works the other way: you give him a .csv file, and it dumps it
into your database, in a 'tmp_imports' schema (makes it easy for
cleaning...).
These utility scripts are very rough: all fields are considered as
strings (varchar), to be as generic as possible.
I use these 2 utilities in production daily, for a number of purposes,
including heavy diff'ing. So far, no worries, they proved to be very
reliable,
There are a couple of environment variables that should be just adapted
for a generic use: $GLL_BD_HOST and $GLL_BD_NAME.
My little 0.02€...
À+
Pierre
--
____________________________________________________________________________
Pierre Chevalier
PChGEI: Pierre Chevalier Géologue Et Informaticien
Partenaire DALIBO
Mesté Duran
32100 Condom
Tél+fax : 09 75 27 45 62
06 37 80 33 64
Émail : pierrechevaliergeolCHEZfree.fr
icq# : 10432285
jabber: pierre(dot)chevalier1967(at)jabber(dot)fr
http://pierremariechevalier.free.fr/pierre_chevalier_geologue
____________________________________________________________________________
From | Date | Subject | |
---|---|---|---|
Next Message | Gilberto Castillo | 2016-02-18 14:08:02 | Re: [MASSMAIL]Re: oracle db reads from postgresql |
Previous Message | Shreeyansh Dba | 2016-02-18 01:28:03 | Re: oracle db reads from postgresql |