MongoDB Drop Collection 💥
Delete Collection
You can delete a table, or collection as it is called in MongoDB, by using the drop() method.
✨ Drop Collection
python
import pymongo
myclient = pymongo.MongoClient("mongodb://localhost:27017/")
mydb = myclient["mydatabase"]
mycol = mydb["customers"]
mycol.drop()✅ Return Value
The drop() method returns true if the collection was dropped successfully, and false if the collection does not exist.
⚠️ Watch Out!
Be careful with the drop() method. Deleting a collection will result in loss of complete information stored in the collection!