Skip to content

Setting up pgAdmin4

The pgAdmin4 UI makes it very easy to explore your data, inspect database internals, and make manual changes while developing features, but before you can make use of this excellent interface, you have to log in and set up database connection(s).

Logging into the pgAdmin4 database administration UI

To access the pgAdmin4 database administration UI, go to http://localhost:5678 and log in using credentials defined in the initial setup step.

  • Email Address / Username: use the PGADMIN_DEFAULT_EMAIL value in your .env file, and
  • Password: use the PGADMIN_DEFAULT_PASSWORD value in your .env file.

pgAdmin4 Web UI Login

Setting up database connections in pgAdmin4

This platform uses two separate databases: one as a backend for Airflow, and the other as the data warehouse database.

Airflow Metadata db contents Sample Exploration of a DWH table

Before you can use pgAdmin4's interface to explore databases in either of these database servers, you have to set up connections to those database servers.

pgAdmin4 Add New Server

The values needed to set up these connections will mainly come from a dot-env file (.env or .env.dwh) or from service names in the docker-compose.yml file.

Airflow Metadata Database

To create a new connection, start by clicking the "Add New Server" button (you might have to click the "Servers" line in the lefthand tray first).

Register Server: General tab

  • Name: airflow_metadata_db
    • This can be whatever you want, it's just the label that pgAdmin4 will use for the connection.

Don't worry about the Server group field, the default is fine.

Register airflow_metadata_db server general

Register Server: Connection tab

  • Host name/address: airflow_db
    • This is defined here in the docker-compose.yml file
  • Port: 5432
    • This is the database's port number inside the container, as defined to the right of the colon here.
  • Username: the POSTGRES_USER value in your .env file.
  • Password: the POSTGRES_PASSWORD value in your .env file.

The defaults for Maintenance database, Role, Service, and the two toggles (of postgres, blank, blank, off, and off, respectively) are all fine.

Register airflow_metadata_db server connection

Then press Save to finalize the connection.

Data Warehouse Database

Repeat the process to connect to the data warehouse database.

Register Server: General tab

  • Name: data_warehouse_db
    • As before, this can be whatever you want

pgAdmin4 airflow_metadata_db connection

Register Server: Connection tab

  • Host name/address: dwh_db
    • This is defined here in the docker-compose.yml file
  • Port: 5432
    • This is the database's port number inside the container, as defined to the right of the colon here
  • Username: the DWH_POSTGRES_USER value in your .env file
  • Password: the DWH_POSTGRES_PASSWORD value in your .env file

The defaults for Maintenance database, Role, Service, and the two toggles (of postgres, blank, blank, off, and off, respectively) remain all fine.

pgAdmin4 airflow_metadata_db connection

Press Save to finalize the connection.

Now pgAdmin4 is configured! Click around, explore the dropdowns, right-click things and see what you see. This is an excellent way to learn about the internals of postgres!

There's a lot going on under the hood!