I am learning to use PostgreSQL and the psql command line tools.
In the tutorial, you import a large CSV file into an existing table.
The tutoral says to use:
COPY master_plan FROM '[PATH TO DIRECTORY]/master_plan.csv' WITH DELIMITER ',' HEADER CSV;
I filled in the PATH with the correct path information but it wouldn't import the data stating:
ERROR: could not open file "[PATH TO DIRECTORY]master_plan.csv" for reading: Permission denied
Doing a search for this suggested a couple of fixes:
Open up your entire "\home\<you>" to the world (Not gonna happen)
Move the file to the "\tmp" directory (Tried, didn't work)
Don't use the "COPY" command, use the "\\copy" command. (This worked!)
But...
I am using a Makefile to run the script so I had to change the target from :
- import: master
@echo "COPY import.master_plan FROM $(CSV) WITH DELIMITER ',' HEADER CSV;" >> $(BUILD)
to:
- import: master
@echo "\\copy import.master_plan FROM $(CSV) WITH DELIMITER ',' HEADER CSV;" >> $(BUILD)
And yes, there are two backslashes before the word "copy".