Kaper_Di
(Kaper Di)
1
Friends are learning how to connect to mongodb over fastapi using the async motor driver.
I’ve highlighted two ways to connect to mongodb that people use.
- one generic client to mongodb (for example, when running an application).
- For each request, create an AsyncIOMotorClient() client usually in
@app.on_event(“startup”)
And close it in
@app.on_event(“shutdown”).
What is the correct and most economical way to connect to async(motor) mongodb. and is it necessary to close the connection?
wan
(Wan Bachtiar)
2
Hi @Kaper_Di and welcome to the forums!
Please have a look at a similar post below, and see whether this answer your question
Regards,
Wan.
1 Like