Re: Piping CSV data to psql when executing COPY .. FROM STDIN (Solved) - Mailing list pgsql-general

From Roberts, Jon
Subject Re: Piping CSV data to psql when executing COPY .. FROM STDIN (Solved)
Date
Msg-id 1A6E6D554222284AB25ABE3229A9276201A19DA6@nrtexcus702.int.asurion.com
Whole thread Raw
In response to Re: Piping CSV data to psql when executing COPY .. FROM STDIN (Solved)  (Allan Kamau <allank@sanbi.ac.za>)
List pgsql-general
> I am however unable to do the same successfully (the Java code simply
> hangs, probably as a result of the second psql not getting the input
to
> it) from Java code using objects of ProcessBuilder and Process. I have
> used threads consume the STDOUT and STDERR streams (I write the STDOUT
> stream to file) do the waitFor(), then I read the file contents and
> write them to STDIN stream of the second call to psql.


> I have therefore resorted to password-less ssh. So far all is well. Am
> writing to CSV file which I scp to the remote server then I issue
> another call to psql to connect to the remote server's PostgreSQL and
> execute an sql having a COPY abc FROM ..

Why aren't you using \COPY from psql rather than COPY?  With \COPY, you
can execute the commands from your remote client without having to do
the SSH stuff.  It may run a bit longer but it is easier to maintain and
looks to be more secure.



Jon

pgsql-general by date:

Previous
From: "Igor Neyman"
Date:
Subject: excluding tables from VACUUM ANALYZE
Next
From: Thomas Guettler
Date:
Subject: Re: Schema Upgrade Howto