Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Welcome to this Tigris MongoDB compatibility and Python 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.

License

Notifications You must be signed in to change notification settings

tigrisdata-archive/tigris-mongodb-python-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️ 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/

Tigris MongoDB compatibility and Python FastAPI example

Introduction

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.

Prerequisites

Preparing Tigris

  1. Create a project in Tigris.
  2. Create an application key, and copy the Project Name, Client ID, and Client Secret values.

Setting up the environment

Activate your Python virtualenv and install dependencies.

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Add 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}"

Run the app

Start the app as follows:

uvicorn app:app --reload

API endpoints

Create 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}'

About

Welcome to this Tigris MongoDB compatibility and Python 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.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages