Manage connections with pymongo

Hi everyone, I’m newbie on MongoDB and Pymongo, be patient. I am developing a program with Python that I need to insert data from MQTT devices each X seconds. When I initialize vaiables, I create a connection with mongoDB with my remote server but when the MQTT message arrive and I try to insert document with the MongoClient instance previously created I get an exception (Type Error ‘Client’ object is not suscriptable). However, if I create a new instance of MongoClient just before the insertOne method, there is no problem and it works fine. My question is if I have to recreate instances of MongoClient each time I want to insert documents or there is another more appropiate way to do this.
Thanks in advance!