Re: COPY to STDOUT and pipes - Mailing list pgsql-general

From Klint Gore
Subject Re: COPY to STDOUT and pipes
Date
Msg-id 48044EE1.6090003@une.edu.au
Whole thread Raw
In response to COPY to STDOUT and pipes  (kevin kempter <kevin@kevinkempterllc.com>)
List pgsql-general
kevin kempter wrote:
> Hi List;
>
>
> I want to run a copy (based on a select) to STDOUT and pipe it to a
> psql copy from STDIN on a different host.
>
> here's what I have:
>
> 1) a .sql file that looks like this:
>
> copy (
> select
>   cust_id,
>   cust_name,
>   last_update_dt
> from sl_cust
> )
> to STDOUT
> with delimiter '|'
>
>
> This works.
>
> However I want to pipe the resulting data into a psql statement that
> does a copy IN to a table on another host. I can't seem to get it
> right. I tried this:
>
> psql -f file1.sql | psql -h newhost -f file2.sql
>
> where file1.sql is the copy statement above and file2.sql does a copy
> table from STDIN with delimiter '|'
>
> Any thoughts on what I'm doing wrong?
no database unless your logged in as someone with the same name as the
databases on both servers?

C:\>psql -d gpdms_nunit -c "copy (select * from pg_class) to stdout with
delimiter '|'" | psql -d gpdms -c "create table foo (like pg_class);
copy foo from stdin with delimiter '|';"

works for me on 8.3.0 win32

klint.

--
Klint Gore
Database Manager
Sheep CRC
A.G.B.U.
University of New England
Armidale NSW 2350

Ph: 02 6773 3789
Fax: 02 6773 3266
EMail: kgore4@une.edu.au


pgsql-general by date:

Previous
From: Craig Ringer
Date:
Subject: Re: COPY to STDOUT and pipes
Next
From: Csaba Nagy
Date:
Subject: Copying large object in a stored procedure