php和python中的MongoDB shell的db.stats() [英] MongoDB shell's db.stats() in php and python
本文介绍了php和python中的MongoDB shell的db.stats()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以从Mongo shell中看到统计信息
I can see the statistics from Mongo shell as
db.stats()
或
db.collection_name.stats()
如何查看来自PHP和Python的数据库或集合的统计信息.
How do I view statistics of a database, or of a collection, from PHP and Python.
编辑: 我已经用PHP完成了,但仍然无法在Python中完成.
EDIT: I have done it in PHP but still cant do it in Python.
帮助?
推荐答案
如果使用PyMongo
驱动程序,这是在Python
中进行的操作:
This is how you do it in Python
if you are using the PyMongo
driver:
connection = pymongo.Connection(host = "127.0.0.1", port = 27017)
db = connection["test_db"]
test_collection = db["test_collection"]
db.command("dbstats") # prints database stats for "test_db"
db.command("collstats", "test_collection") # prints collection-level stats for "test_collection" under "test_db".
参考:
这篇关于php和python中的MongoDB shell的db.stats()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文