Re: Piping CSV data to psql when executing COPY .. FROM STDIN (Solved)

From: "Roberts, Jon" <Jon(dot)Roberts(at)asurion(dot)com>
To: "Allan Kamau" <allank(at)sanbi(dot)ac(dot)za>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Piping CSV data to psql when executing COPY .. FROM STDIN (Solved)
Date: 2008-10-30 12:56:22
Message-ID: 1A6E6D554222284AB25ABE3229A9276201A19DA6@nrtexcus702.int.asurion.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Fetter 2008-10-30 13:09:06 Re: Schema Upgrade Howto
Previous Message Tom Lane 2008-10-30 12:00:45 Re: Can't restart Postgres