Re: psql -f COPY from STDIN
От | Tarlika Elisabeth Schmitz |
---|---|
Тема | Re: psql -f COPY from STDIN |
Дата | |
Msg-id | 20101113120135.6b7fdc9e@dick.coachhouse обсуждение исходный текст |
Ответ на | Re: psql -f COPY from STDIN (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: psql -f COPY from STDIN
Re: psql -f COPY from STDIN |
Список | pgsql-sql |
On Fri, 12 Nov 2010 22:22:11 -0500 Tom Lane <tgl@sss.pgh.pa.us> wrote: >Tarlika Elisabeth Schmitz <postgresql2@numerixtechnology.de> writes: >> The following command works fine when pasing it to psql via the -c >> option: > >> cat event.csv | \ >> psql -c "COPY (event_id, event_name) FROM STDIN DELIMITER AS ',' NULL >> AS ''" > >> When executed from a file via -f, it does nothing > >> event.sql: >> COPY (event_id, event_name) FROM STDIN DELIMITER AS ',' NULL AS '' > >> cat event.csv | psql -f event.sql > >[...] > >I think you can get the effect you're after using \copy ... from >pstdin. See the psql man page. Thank you for your reply, Tom. I had not appreciated the difference between \COPY and COPY. The psql command is executed on the client; the import data are on the client, so I ought to use \COPY. Strangely, cat event.csv |psql -c "COPY ... worked, presumably because both the COPY command and data came from the same source (client stdin). I changed event.sql (3 lines): \COPY (event_id, event_name) FROM STDIN DELIMITER AS ',' NULL AS '' Now I am getting error messages: psql:event.sql:1: \copy:parse error at end of line psql:event.sql:4: ERROR:syntax error at or near "event_id" LINE 1: (event_id, When I remove the linefeeds I don't get errors but it does not import anything. I'd like the store the COPY command in a separate file without specifying an input file name. I want to feed it the data from the shell script that calls psql -f. -- Best Regards, Tarlika Elisabeth Schmitz
В списке pgsql-sql по дате отправления: