Where to store the database client in FastAPI?
I have a FastAPI app with MongoDB connected via Motor. I open a MongoDB connection at the beginning of an app and close it at the end using lifespan. Reading documentation and other people’s Github repositories I have found 3 main ways to store the client.