Skip to content

Migrate to Pymongo Async from Motor #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
from typing_extensions import Annotated

from bson import ObjectId
import motor.motor_asyncio
import asyncio
from pymongo import AsyncMongoClient
from pymongo import ReturnDocument


app = FastAPI(
title="Student Course API",
summary="A sample application showing how to use FastAPI to add a ReST API to a MongoDB collection.",
)
client = motor.motor_asyncio.AsyncIOMotorClient(os.environ["MONGODB_URL"])
client = AsyncMongoClient(os.environ["MONGODB_URL"])
db = client.college
student_collection = db.get_collection("students")

Expand Down
4 changes: 1 addition & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@ idna==3.4
# via
# anyio
# email-validator
motor==3.3.1
pymongo==4.13
# via -r requirements.in
pydantic==2.6.3
# via
# -r requirements.in
# fastapi
pydantic-core==2.16.3
# via pydantic
pymongo==4.5.0
# via motor
sniffio==1.3.0
# via anyio
starlette==0.36.3
Expand Down