Python MongoDB Delete Collection
- Previous Page MongoDB Delete
- Next Page MongoDB Update
Delete Collection
You can use drop()
The method deletes the table or collection called in MongoDB.
Instance
Delete "customers" collection:
import pymongo myclient = pymongo.MongoClient("mongodb://localhost:27017/") mydb = myclient["mydatabase"] mycol = mydb["customers"] mycol.drop()
If the collection is successfully deleted then drop()
The method returns true if the collection does not exist, otherwise it returns false.
- Previous Page MongoDB Delete
- Next Page MongoDB Update