M using pymongo for connecting with a mLab-hosted mongodb.
I need to keep pinging the server occassionally to keep the connection alive.
I have not been able to find documentation for that.
Kindly suggest the pymongo equivalent of ping command.
You can use pymongo.database.Database.command to send custom command like:
from pymongo import MongoClient
client = MongoClient()
client.db_name.command('ping')
returns
{u'ok': 1.0}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With