Refine your SQL skills using pg-dock-sql—a PostgreSQL Docker environment for hands-on coding challenges and solutions. This helps to elevate your proficiency in SQL through handson experience.
git clone git@github.com:sibyabin/pg-dock-sql.git
cd pg-dock-sql
The directory will look like the below.
export POSTGRES_DB=practise
export POSTGRES_USER=dbuser
export POSTGRES_PASSWORD=<password>
sh launch-environment.sh
docker ps
command to check if the container started without issues
docker exec -it postgres psql -v --username dbuser --dbname practise -c "\dn"
Under scripts folder , create a folder structures in the format exercise-<some_number>
.
For e.g., example-111
├── exercise-111
│ ├── code
│ │ └── setup.sql
│ │ ├── expected.sql
│ │ └── solution.sql
│ ├── README.md
│ └── tests
│ └── test1.sql
Execute the command sh check-solution.sh <some_number>
on your system to validate the solution. This script will establish a connection with the PostgreSQL Docker container, execute your provided solution, and display both the expected and actual outputs. some_number can be any number between 101 to 200
Execute the command sh stop-environment.sh
to halt the containers when you are not actively working on them.
Execute the command sh cleanup-environment.sh
to cleanup the environment (containers, networks, images, volumes etc) permanently.