Creating an Atlas instance and a collection
Log in to your Atlas account, and create a new database called carBackend
inside a collection named cars
. You can refer to Chapter 2, Setting Up the Database with MongoDB. After creating the database and the collection, take note of the MongoDB connection string and save it in a text file for later, when you will be creating your secret environment keys.
Setting up the Python environment
After creating the MongoDB database on Atlas and connecting it, it is time for you to set up a brand new Python virtual environment and install the requirements:
- First, create a plain text file called
requirements.txt
and insert the following lines in it:fastapi==0.111.0 motor==3.4.0 uvicorn==0.29.0 pydantic-settings==2.2.1
- The package versioning is important if you want to be able to reproduce exactly the code used in this book and you can always refer to the
requirements.txt
file in the book’s repository. Run thepip
installation...