This is a set of coding examples that will help you learn how to use MongoDB. We use Jupyter Notebooks because of their interactivity and inmediate feedback. This, along with the ability to include instructions mixed with code facilitates our approach of learning by doing and testing new concepts.
If you've never used Jupyter Notebooks, here is a one-page quick start.
We use this lab during our Developer Days Labs, to speed up the time from theory to code. We also use it in webinars, MongoDB .Local Labs / demos and during customer meetings or Design Reviews.
- Log in to your Github Account. This is needed to start a new Codespace.
- If you log in with your enterprise / organization account maybe they have restricted the use of Codespaces. In that case use your personal Github account.
- Click this button
- This will create a couple Docker containers, open Visual Studio Code in the browser and clone the repo.
- Wait for the Codespace to finish loading. You know everything has finished when you see the MongoDB Visual Studio Code extension loaded at the left (looks like a leaf)
- Navigate to the examples you want to run and click on the run icon. You'll be asked to choose a kernel. Pick Python.
- Install Docker in your system
- Clone the repo:
git clone https://github.com/mongodb-developer/query-api-python-lab - Install Visual Studio Code
- Open the repo from VSC, open the Command Palette, select
Dev Containers: Rebuild and reopen in Container - The lab will start two containers (see section below)
We aim to have the same set of examples for each supported language. Right now you have available:
The Library database in included, along with a pre-defined connection inside the MongoDB Visual Studio Code extension. Just open the extension and click on the connection to browse the Library database.
There are two versions of this database. One includes vector embeddings for the books, in case you want to try Atlas Vector Search.
If you need to restore the original data, open a Terminal in Visual Studio code and type:
.devcontainer/import.sh - 3000: Jupyter notebooks
- 27017: MongoDB Atlas local instance
If you clone this repo and run it locally (using VS Code) or start a new Codespace, you'll start two containers:
- an Atlas Local Cluster, that has a MongoDB database server with the Library dataset imported (see
.devcontainer/import.sh). - a Linux Ubuntu container with some development tools:
- Python (installed through
.devcontainer/setup.sh) - Deno (installed through
.devcontainer/setup.sh) - Jupyter notebook server (installed through
.devcontainer/setup.sh) - The MongoDB database tools (installed through
.devcontainer/install-mongodb-db-tools.sh)
- Python (installed through