I want to read the data from mongoDB in every 5 minutes in python. I am able to read the data in using pymongo. But, thats one time. I want to establish mongoDB connection in every 5 minutes and look for new documents.
client = MongoClient('localhost', 27017)
db = client.test_insert
collection = db.dataset
for docs in db.dataset.find():
print docs
But I have to manually do it. Can I make it sleep for 5 minutes and then again establish a connection with the database? Please help..