如何通过python中的pymongo获取db.serverStatus().connections的输出? [英] How to get output of db.serverStatus().connections through pymongo in python?
本文介绍了如何通过python中的pymongo获取db.serverStatus().connections的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在mongodb shell中,"db.serverStatus().connections
"给出如下输出:
In mongodb shell "db.serverStatus().connections
" gives output something like:
{
"current" : 43,
"available" : 51157,
"totalCreated" : NumberLong(3988)
}
所以,我关心的是如何通过pymongo获得相同的输出.??
So, my concern is how to get the same output through pymongo.??
推荐答案
Issue the MongoDB command
"serverStatus" to get the output and save it to a variable:
connections_dict = db.command("serverStatus")["connections"]
这篇关于如何通过python中的pymongo获取db.serverStatus().connections的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文