This repository hosts public course material for the Data Modeling and Databases course at ETH given by Prof. Ce Zhang. The main purpose is to host the interactive tutorials on Katacoda.
Prerequisites:
Start a Postgres server:
docker run -d \
-p 5432:5432 \
-v /:/host/:ro \
--name postgres-server \
-e POSTGRES_HOST_AUTH_METHOD=trust \
postgres:13.2-alpineNothing else should be required. This launches a docker container in the background. You can see the running containers with the following command:
docker psThe container you just run should show up in the output (called
postgres-server). You can now stop and start that container with the
following commands:
docker stop postgres-server
docker start postgres-serverThis should preserve the databases you have created inside the container. If you want to remove it completely (including the databases), use the following:
docker rm postgres-serverYou can run the standard Postgres command line client inside that container
like this (setting the user to postgres):
docker exec -it postgres-server psql -U postgresThe same way, you can start a shell inside that container:
docker exec -it postgres-server psql -U bashTo use pgcli instead, run the following:
docker run --rm -it \
--link postgres-server \
-v /:/host/:ro \
-v $HOME/.config/pgcli/:/root/.config/pgcli/ \
ds3lab/pgcli -h postgres-server -U postgresBoth containers are run such that the entire host file system is available
(read-only) under /host/ inside of the containers. If you need to import
files inside the containers, access the files accordingly. Also, for pgcli,
the config folder of your home directory is mounted into the container such
that the configuration and command history is shared with the host.
Prerequisites:
- Python with
pip
You may also be able to install pgcli on your own
machine. Normally, the following is enough:
pip3 install pgcliHowever, you need a basic compiler infrastructure and the Postgres client library installed. On Debian, Ubuntu, etc, the following may do that:
sudo apt install build-essential libpq-devAlternatively, you may be lucky with installing an old version:
pip install pgcli==2.1.1 --only-binary psycopg2