Last active
February 13, 2023 02:15
-
-
Save gh0st026/f02847cd6e680d484c26cafd460f3ef4 to your computer and use it in GitHub Desktop.
Dump PostgreSQL Table in docker container as CSV file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONTAINER="name" | |
DB="Db name" | |
TABLE="Table Name" | |
FILE="file.csv" | |
sudo docker exec -u postgres ${CONTAINER} psql -d ${DB} -c "COPY ${TABLE} TO STDOUT WITH CSV HEADER " > ${FILE} |
psql: error: FATAL: role "postgres" does not exist
-u YOUR_POSTGRES_USERNAME
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
psql: error: FATAL: role "postgres" does not exist