0

I'm trying to delete a collection in mongodb via pymongo,but its not deleting.Where did i go wrong? I have check in stackoverflow for different ways to delete a collection but its not working. Help please

code: https://pastebin.com/LEAJXvHP

2 Answers2

0

It worked for me to use drop_collection (collection_name) to remove collections. (Python 2.7 and using pymongo)

Example:

mongoClient = MongoClient("xx.xx.xx.xx:27017")
db = mongoClient["DB_name"]
db.drop_collection ("collection_name")

I hope it helps you. Regards,

MauriRamone
  • 469
  • 1
  • 3
  • 21
0

Beeing "mongo" the variable name that holds the instance of PyMongo, mongo.db.drop_collection("collection_name") should do the trick.

alexdefelipe
  • 169
  • 2
  • 8