From 05bc83d6c6bf7f6af22107d8926f542da86cb21b Mon Sep 17 00:00:00 2001 From: swve Date: Tue, 28 Feb 2023 23:32:17 +0100 Subject: [PATCH] feat: use motor instead of pymongo --- requirements.txt | 3 ++- src/core/events/database.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 155368e7..d1f1bd3a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,8 @@ fastapi==0.92.0 pydantic>=1.8.0,<2.0.0 uvicorn==0.20.0 -pymongo==4.1.1 +pymongo==4.3.3 +motor==3.1.1 python-multipart python-jose passlib diff --git a/src/core/events/database.py b/src/core/events/database.py index 22a6038c..56913242 100644 --- a/src/core/events/database.py +++ b/src/core/events/database.py @@ -1,11 +1,11 @@ import logging from fastapi import FastAPI -import pymongo +import motor.motor_asyncio async def connect_to_db(app: FastAPI) : logging.info("Connecting to database...") try: - app.mongodb_client = pymongo.MongoClient("mongodb://learnhouse:learnhouse@mongo:27017/") # type: ignore + app.mongodb_client = motor.motor_asyncio.AsyncIOMotorClient("mongodb://learnhouse:learnhouse@mongo:27017/") # type: ignore app.db = app.mongodb_client["learnhouse"] # type: ignore logging.info("Connected to database!") except Exception as e: