I want to import a csv file, into the postgreSQL table inside the docker-compose container from the image postgres:12. I can read the file from the application backend, for example:
pd.read_csv(pth.dirname(__file__) + '/file_name.csv')
Where file path is:
/opt/project/backend_api/directory_name
but when I try to access the same file from the container \copy data_table(id, ...) FROM '/opt/project/backend_api/directory_name/file_name.csv' DELIMITER ',' CSV HEADER;
No such file or directory error.
So how I can allow to the container to read this path, or how to add the file to location where I'll be able to reach it?
...how to add the file to location where I'll be able to reach it?
Since your container already running, you can copy the file into the container: docker cp file_name.csv <container id>:/opt/project/backend_api/directory_name/file_name.csv
and try your pg command.