Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind Python MongoDB Drop Collection?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
1Quick choice
Which statement best captures the main point of this lesson?
2Fill blank
Complete the missing token from the example code.
___ pymongo3Order
Put the learning moves in the order that makes the concept easiest to apply.
The drop() method returns true if the collection was dropped successfully, and false if the collection does not exist.
Delete the "customers" collection:
You can delete a table, or collection as it is called in MongoDB, by using the drop() method.
Delete Collection
You can delete a table, or collection as it is called in MongoDB, by using the drop() method.
Example
Delete the "customers" collection:
import pymongo
myclient = pymongo.MongoClient("mongodb://localhost:27017/")
mydb = myclient["mydatabase"]
mycol = mydb["customers"]
mycol.drop()The drop() method returns true if the collection was dropped successfully, and false if the collection does not exist.