【发布时间】:2015-02-02 13:13:36
【问题描述】:
在mongo 命令行中我可以运行
db.my_collection.stats()
我需要从 Python 获取我的收藏统计信息,所以我尝试了
from pymongo import MongoClient
client = MongoClient()
db = client.test_database
collection = db.test_collection
collection.stats()
但我明白了
TypeError: 'Collection' object is not callable.
If you meant to call the 'stats' method on a 'Collection' object it is failing because no such method exists.
这是因为pymongo 不支持这种方法。如何通过Python 将原始mongoDB 命令发送到mongo?
【问题讨论】: