1

I have a dockerized Postgres container that I can manipulate from the shell using psql. I would like to fill the cities table from a CSV file:

\copy cities(location, latitude, longitude) FROM 'postgis.csv' DELIMITERS ',' CSV HEADER;

However, this command returns "postgis.csv: No such file or directory". How can I do the above in Docker and PostgreSQL? I've tried editing my docker compose file by adding

volumes:
  - ./src/db/pgdata:/var/lib/postgresql/data

And now I have the database data folder locally, but not sure where I should put the CSV file. Sorry for the noob question.

3
  • does your local ./src/db/pgdata folder contains this csv file? if so, what about copy cities(location, latitude, longitude) FROM '/var/lib/postgresql/data/postgis.csv' DELIMITERS ',' CSV HEADER; Commented Dec 26, 2020 at 13:55
  • How is the question programming-related? The question might be better suited for SuperUser or ServerFault. Commented Dec 26, 2020 at 13:57
  • 1
    Thanks a lot @ItayB! That worked. Maybe I can flag so that a mod can move this to the appropriate site. Apologies for this. Commented Dec 26, 2020 at 14:13

1 Answer 1

1

does your local ./src/db/pgdata folder contains this csv file?

if so, what about

copy cities(location, latitude, longitude) FROM '/var/lib/postgresql/data/postgis.csv' DELIMITERS ',' CSV HEADER;

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.