mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: use motor instead of pymongo
This commit is contained in:
parent
0a7aafcc00
commit
05bc83d6c6
2 changed files with 4 additions and 3 deletions
|
|
@ -1,7 +1,8 @@
|
||||||
fastapi==0.92.0
|
fastapi==0.92.0
|
||||||
pydantic>=1.8.0,<2.0.0
|
pydantic>=1.8.0,<2.0.0
|
||||||
uvicorn==0.20.0
|
uvicorn==0.20.0
|
||||||
pymongo==4.1.1
|
pymongo==4.3.3
|
||||||
|
motor==3.1.1
|
||||||
python-multipart
|
python-multipart
|
||||||
python-jose
|
python-jose
|
||||||
passlib
|
passlib
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import logging
|
import logging
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
import pymongo
|
import motor.motor_asyncio
|
||||||
|
|
||||||
async def connect_to_db(app: FastAPI) :
|
async def connect_to_db(app: FastAPI) :
|
||||||
logging.info("Connecting to database...")
|
logging.info("Connecting to database...")
|
||||||
try:
|
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
|
app.db = app.mongodb_client["learnhouse"] # type: ignore
|
||||||
logging.info("Connected to database!")
|
logging.info("Connected to database!")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue