Created
July 24, 2018 19:05
-
-
Save mjumbewu/3daace7d8a98caba55032ba0bcb1e834 to your computer and use it in GitHub Desktop.
Shell script to dump a CSV file from a database table
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
#!/bin/sh -e | |
table=$1 | |
psql -U $DBUSER -h $DBHOST -p $DBPORT $DBNAME -c \ | |
"COPY (SELECT * FROM $table) TO STDOUT WITH CSV HEADER" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment