Re: \COPY in script

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Binand Sethumadhavan <binand(at)gmx(dot)net>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: \COPY in script
Date: 2016-10-07 17:29:28
Message-ID: 15509.1475861368@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Binand Sethumadhavan <binand(at)gmx(dot)net> writes:
> I am trying to do a summary query in one DB, and populate a table in another.
> This is how I'm doing it:

> psql -h db1 -d d1 -U u1 -A -F, -t -f a.sql | psql -h db2 -d d2 -U u2 [...]

> Now, this ellipsis is what is causing consternation.

> 1. If the ellipsis is -c "$( < b.sql )" my target table gets populated.
> 2. If the ellipsis is -f b.sql my target table does not get populated.

> My b.sql is as follows:

> \COPY table_name FROM STDIN CSV

> That's it. Why does (1) work but (2) does not?

I think you want "pstdin" not "stdin". See the description of \copy
in the psql man page.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Binand Sethumadhavan 2016-10-10 17:32:58 Re: \COPY in script
Previous Message Binand Sethumadhavan 2016-10-07 17:14:05 \COPY in script