0

This is the sample Python code that I used to write data in MongoDB database. After every connection close, I restart the program and I noticed an accumulation in memory count in the Task Manager. Anyone could guide me on this?

from pymongo import MongoClient
from datetime import datetime
from pymongo import MongoClient
import time as t

CONNECTION_STRING = "mongodb://localhost:27017/"

with MongoClient(CONNECTION_STRING) as client:
    dbname = client['TESTING']
    collection_name = 'JUNE'
    collection = dbname[collection_name]
    

    for i in range(1000):
        now = datetime.now()
        real_time = now.strftime("%Y/%m/%d-%H:%M:%S")
        body = {'Plant': 'MSIT', 'Packet': 'TESTINGS', 'TimeStamp': real_time}
        print(i)
        collection.insert_one(body)
    client.close()

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.