How to run raw mongodb commands from pymongo

前端 未结 2 780
轻奢々
轻奢々 2020-12-30 07:08

In a mongo command line I can run

db.my_collection.stats()

I need to get my collections stats from Python so I t

2条回答
  •  悲&欢浪女
    2020-12-30 07:14

    from pymongo import MongoClient
    
    client = MongoClient()
    
    db = client.test_database
    
    print(db.command("collstats", "test_collection"))
    

提交回复
热议问题