Metabase
This guide shows you how to work with Metabase locally using Docker Compose, PostgreSQL, and SQLAlchemy. This lab demonstrates how to insert data into a PostgreSQL database and explore it using Metabase.
Prerequisites
Section titled “Prerequisites”- Docker installed and running.
- Dev Containers extension installed (optional).
How to execute
Section titled “How to execute”-
Setup Environment:
Open VS Code in the project folder and execute this command in the Command Palette:
Terminal window > Dev Containers: Reopen in ContainerTerminal window pip3 install uv && uv sync -
Start Infrastructure: Launch Metabase and PostgreSQL:
Terminal window docker compose up -d -
Run the Example:
Terminal window python main.py
Validate results
Section titled “Validate results”- Open the Metabase UI:
Terminal window http://localhost:3000 - Complete the initial setup and create an admin account.
- Connect PostgreSQL using the credentials defined in
.env(METABASE_DB,METABASE_USER,METABASE_PASSWORD,POSTGRES_HOST,POSTGRES_PORT). - Explore the
productstable and create visualizations.
Connect using DBeaver with the connection details defined in .env and run:
SELECT * FROM products;Clean Up
Section titled “Clean Up”docker compose down -vTroubleshooting
Section titled “Troubleshooting”| Issue | Solution |
|---|---|
Port 3000 or 5432 in use | Change the port mapping in docker-compose.yml and restart. |
| Metabase not loading | Wait for initialization — check logs: docker compose logs -f metabase (look for “Initialization COMPLETE”). |
| Connection Refused | Ensure both containers are running: docker ps |
| Module Not Found | Reinstall dependencies: pip3 install uv && uv sync |