How to execute SQLs in the docker Postgres db

Task: Write script to execute SQL commands in the docker Prostgers DB

Script:

docker exec -I <db docker name> psql -U <username> <<-EOSQL
  DROP DATABASE IF EXISTS dbname;
  CREATE DATABASE dbname;
EOSQL

Import dump file:

docker exec -I <db docker name> psql -U <username> < dumpfile.sql

Done.

Leave a Reply

Your email address will not be published. Required fields are marked *

7  +  3  =  

Skynin cache:
Array ( [cache mode] => capture [requestKey] => 93320a38c20e1d748a89f8e56e812833ba.sc [skycache_disable_capture] => false )