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.