Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Dump PostgreSQL Table in docker container as CSV file
DB="Db name"
TABLE="Table Name"
sudo docker exec -u postgres ${CONTAINER} psql -d ${DB} -c "COPY ${TABLE} TO STDOUT WITH CSV HEADER " > ${FILE}
# Copy csv to table
# sudo psql -h localhost -U root -d my_db -p 5432 -c "\COPY source_table TO '/home/user/source_table.csv' DELIMITER ',' CSV HEADER;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment