Created
April 10, 2017 21:43
-
-
Save RWaltersMA/4486dddcdd064fc289e52b65457fb426 to your computer and use it in GitHub Desktop.
Issuing a MongoDB command from PyMongo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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