vendredi 20 janvier 2017

What is the proper way to share MongoClient using flask_pymongo in larger application?

I'm building a REST API using flask_restful and I am currently looking into connecting it to a MongoDB database. I've been looking a bit on flask_pymongo and if I've understood correctly you create an object representing the connection and use this object for your queries.

In the examples I've seen one single file is used and the object is global. In a larger project I will need to share this object in some way. Will I have to make this object global or is there any better way to handle it?

Aucun commentaire:

Enregistrer un commentaire