我可以从 Mongo shell 中看到统计数据
db.stats()
或
db.collection_name.stats()
如何从 PHP 和 Python 查看数据库或集合的统计信息。
编辑: 我已经用 PHP 完成了,但仍然不能用 Python 完成。
帮忙吗?
最佳答案
如果您使用 PyMongo
驱动程序,这就是您在 Python
中执行此操作的方法:
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".
引用资料:
关于python - MongoDB shell 的 db.stats() 在 php 和 python 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11648627/