如何在python中通过pymongo获取db.serverStatus()。连接的输出?

时间:2016-01-20 11:25:34

标签: python mongodb pymongo

在mongodb shell" db.serverStatus().connections"输出类似于:

{ 
"current" : 43,
"available" : 51157,
"totalCreated" : NumberLong(3988)
}

所以,我关心的是如何通过pymongo获得相同的输出。??

1 个答案:

答案 0 :(得分:3)

发布MongoDB command " serverStatus"获取输出并将其保存到变量:

connections_dict = db.command("serverStatus")["connections"]