⚠️ This repository is archived.Tigris has pivoted from this database project to a new, globally distributed S3-compatible object storage service. Learn more about the new product here: https://www.tigrisdata.com/
Welcome to this Tigris MongoDB compatibility and Python FastAPI example app. This repo aims to give you a working example of how you can use the power of Tigris MongoDB compatibility with Python to create modern web applications.
- Python 3
- A Tigris Cloud account or you can self-host Tigris
- Create a project in Tigris.
- Create an application key, and copy the Project Name, Client ID, and Client Secret values.
Activate your Python virtualenv and install dependencies.
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtAdd an environment variabled named MONGODB_URL with the connection string to Tigris. Be sure to replace {TIGRIS_CLIENT_ID}, {TIGRIS_CLIENT_SECRET}, and {TIGRIS_PROJECT_NAME} with your values.
export MONGODB_URL="mongodb://{TIGRIS_CLIENT_ID}:{TIGRIS_CLIENT_SECRET}@m1k.preview.tigrisdata.cloud:27018/?authMechanism=PLAIN&tls=true"
export TIGRIS_PROJECT_NAME="{TIGRIS_PROJECT_NAME}"Start the app as follows:
uvicorn app:app --reloadCreate a new Game:
curl --location --request POST 'http://localhost:8000/games' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Fable Anniversary",
"price": 4.99,
"category": "Video Game"
}'List Games:
curl --location --request GET 'http://localhost:8000/games'Get a single Game:
curl --location --request GET 'http://localhost:8000/games/{_id}'Delete a Game:
curl --location --request DELETE 'http://localhost:8000/games/{_id}'