I am new to mongo and I use pymongo. I will find documentation for pymongo to be everywhere.
1) I have a set of repressions. From the mongo shell, if I run below, I get what I need.
sudo mongo 111.111.111.111 --eval "printjson(rs.status())" MongoDB shell version: 2.2.1 connecting to: 111.111.111.111/test { "set" : "hey", "date" : ISODate("2012-11-10T11:47:58Z"), "myState" : 1, "members" : [ { "_id" : 0, "name" : "111.111.111.111:27017", "health" : 1, "state" : 1, "stateStr" : "PRIMARY", "uptime" : 69189, "optime" : Timestamp(1352478921000, 1), "optimeDate" : ISODate("2012-11-09T16:35:21Z"), "self" : true } ], "ok" : 1 }
I need to get this information from pymongo.
1) I connect to the primary. I get none , but in the above example, node is the main one:
c = ReplicaSetConnection("111.111.111.111:27017", replicaSet='heythat') print c.primary None
2) I want to run c.command("status") , but this operation is not supported.
So, how can I use pymongo to return primary as well as return status to a Python dictionary?
Tampa source share