Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Fallenstedt/5a0406a3c86e3e96cc2c609cef444e9f to your computer and use it in GitHub Desktop.
Save Fallenstedt/5a0406a3c86e3e96cc2c609cef444e9f to your computer and use it in GitHub Desktop.

Revisions

  1. Fallenstedt revised this gist May 17, 2021. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion docker_export_postgre_table.sh
    Original file line number Diff line number Diff line change
    @@ -3,4 +3,7 @@ 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}
    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;"
  2. @gh0st026 gh0st026 renamed this gist Feb 7, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. @gh0st026 gh0st026 created this gist Feb 7, 2019.
    6 changes: 6 additions & 0 deletions docker_postgre_table.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    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}