![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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 (no error messages either): event.sql: COPY (event_id, event_name) FROM STDIN DELIMITER AS ',' NULL AS '' |
|
cat event.csv | psql -f event.sql What's the problem? Many thanks in advance. |
#3
| |||
| |||
|
|
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 (no error messages either): event.sql: COPY (event_id, event_name) FROM STDIN DELIMITER AS ',' NULL AS '' cat event.csv | psql -f event.sql |
#4
| |||
| |||
|
|
Tarlika Elisabeth Schmitz <postgresql2 (AT) numerixtechnology (DOT) 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. |
arse error at end of line
#5
| |||
| |||
|
|
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 arse error at end of line |
|
When I remove the linefeeds I don't get errors but it does not import anything. |
#6
| |||
| |||
|
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |