Forked from gh0st026/docker_export_postgre_table.sh
          
        
    
          Last active
          May 17, 2021 04:02 
        
      - 
      
- 
        Save Fallenstedt/5a0406a3c86e3e96cc2c609cef444e9f to your computer and use it in GitHub Desktop. 
Revisions
- 
        Fallenstedt revised this gist May 17, 2021 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewingThis file contains hidden or 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 charactersOriginal 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} # 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;" 
- 
        gh0st026 renamed this gist Feb 7, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewingFile renamed without changes.
- 
        gh0st026 created this gist Feb 7, 2019 .There are no files selected for viewingThis file contains hidden or 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 charactersOriginal 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}