Environment
Initial Setup
We have a makefile that will help you setup the database and run the queries. We use Docker to run the database.
Create Database with Docker
$ make run
Login to container with Docker
$ make bash
Login to Database with Docker
$ make exec
Start container
$ make start
Stop container
$ make stop
Delete container
$ make delete
Sample Database for use with PostgreSQL
Please, download this db: Download Link
First, extract the file. Second, you need to login to docker container:
Copy file to docker container
$ docker cp <file_path> <container_name>:<file_path>
Example:
$ docker cp ~/Downdloads/dvdrental.tar postgres:/
After login to docker container, you need to restore the database:
Restore database
$ pg_restore -U postgres -d <db_name> <file_path>
Exapmle:
$ pg_restore -U postgres -d dvdrental /dvdrental.tar
Keep learning . . . 👨💻
Last updated
Was this helpful?