0

For some reason, I have to use python2.7 and pymongo2.7.
The official mannual https://api.mongodb.com/python/2.7.2/api/pymongo/collection.html?highlight=collection#pymongo.collection seems not having an api doc about collection.stats().
With the 2.7 version of those all, how can I get the stats info of a collection or db?

wymli
  • 1,013
  • 1
  • 7
  • 11
  • Try using the `Database#command` - this is equivalent to the native `db.runCommand` where you can specify the `collStats` command. – prasad_ Sep 27 '21 at 10:13
  • @prasad_ do you mean using a mongodb shell client? That could be a method, but my dev env don't have a mongo shell yet. Thank u anyway~ – wymli Sep 27 '21 at 10:26
  • 1
    See this post about the usage of `database#command` in pymongo: https://stackoverflow.com/questions/27297727/how-to-run-raw-mongodb-commands-from-pymongo – prasad_ Sep 27 '21 at 10:30
  • awesome ~~~~~~~~~ – wymli Sep 27 '21 at 12:50

0 Answers0