Skip to content

Commit df59d51

Browse files
authored
Merge pull request #20 from mongodb-developer/move-to-pymongo-async
Migrate to PyMongo Async from Motor
2 parents ff24b15 + ad2600e commit df59d51

File tree

5 files changed

+5
-51
lines changed

5 files changed

+5
-51
lines changed

app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@
99
from typing_extensions import Annotated
1010

1111
from bson import ObjectId
12-
import motor.motor_asyncio
12+
import asyncio
13+
from pymongo import AsyncMongoClient
1314
from pymongo import ReturnDocument
1415

1516

1617
app = FastAPI(
1718
title="Student Course API",
1819
summary="A sample application showing how to use FastAPI to add a ReST API to a MongoDB collection.",
1920
)
20-
client = motor.motor_asyncio.AsyncIOMotorClient(os.environ["MONGODB_URL"])
21+
client = AsyncMongoClient(os.environ["MONGODB_URL"])
2122
db = client.college
2223
student_collection = db.get_collection("students")
2324

dev-requirements.in

Lines changed: 0 additions & 3 deletions
This file was deleted.

dev-requirements.txt

Lines changed: 0 additions & 42 deletions
This file was deleted.

requirements.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
fastapi ~=0.110
2-
motor ~=3.3
2+
pymongo ~=4.13
33
uvicorn ~=0.28
4-
pydantic[email]
4+
pydantic[email]

requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ idna==3.4
2424
# via
2525
# anyio
2626
# email-validator
27-
motor==3.3.1
28-
# via -r requirements.in
2927
pydantic==2.6.3
3028
# via
3129
# -r requirements.in

0 commit comments

Comments
 (0)