Docker + Python CRUD API + Excel VBA – All for beginners

If you are just starting with Docker and want a practical project, here is a fun one: let’s build a tiny CRUD app in Python, run it inside a Docker container, and then connect to it from Excel with VBA. It would not be as fun as it sounds, but it is interesting to see it in action.

The Python App

We use FastAPI and SQLite to build a minimal backend with five endpoints:

  • POST /todos – create
  • GET /todos – list
  • GET /todos/{id} – get one
  • PATCH /todos/{id} – update
  • DELETE /todos/{id} – delete
  • FastAPI automatically gives us a Swagger UI at /docs, where we can test everything without writing any frontend code.

The Dockerfile

With a single Dockerfile we package the app and its dependencies. We expose port 8000 and mount a host folder as /data, so the SQLite database persists even if the container is removed.

Now you can open http://localhost:8000/docs and play with the CRUD operations.

Four ways to display the db data are illustrated in the GitHub repository.

Excel and VBA

To make it even more fun, we fetch the todos directly into Excel. With a few lines of VBA using XMLHTTP and a JSON parser, the /todos endpoint is read into the sheet. That way, Excel becomes a simple client for our Dockerized API:

The GitHub repository is here: https://github.com/Vitosh/Python_personal/blob/master/YouTube/039_Docker-Basics

Enjoy!

Tagged with: , , , , ,