Skip to content

mongodb-developer/query-api-python-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Open in GitHub Codespaces

MongoDB Query API Python Lab

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.

How to use this lab

Running in a GitHub Codespace

  • 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

Open in GitHub Codespaces

  • 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.

Running locally

  • 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)

Available code examples

We aim to have the same set of examples for each supported language. Right now you have available:

Database

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 

open ports

  • 3000: Jupyter notebooks
  • 27017: MongoDB Atlas local instance

Containers

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)

About

MongoDB Query API Python lab

Topics

Resources

License

Stars

Watchers

Forks