Skip to content

Instantly share code, notes, and snippets.

@RWaltersMA
Created April 10, 2017 21:43
Show Gist options
  • Save RWaltersMA/4486dddcdd064fc289e52b65457fb426 to your computer and use it in GitHub Desktop.
Save RWaltersMA/4486dddcdd064fc289e52b65457fb426 to your computer and use it in GitHub Desktop.
Issuing a MongoDB command from PyMongo
from pymongo import MongoClient
# pprint library is used to make the output look more pretty
from pprint import pprint
# connect to MongoDB, change the << MONGODB URL >> to reflect your own connection string
client = MongoClient(<<MONGODB URL>>)
db=client.admin
# Issue the serverStatus command and print the results
serverStatusResult=db.command("serverStatus")
pprint(serverStatusResult)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment