VOOZH about

URL: https://www.geeksforgeeks.org/python/drop-collection-if-already-exists-in-mongodb-using-python/

⇱ Drop Collection if already exists in MongoDB using Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Drop Collection if already exists in MongoDB using Python

Last Updated : 14 Jun, 2022

Using drop() method we can drop collection if collection exists. If collection is not found then it returns False otherwise it returns True if collection is dropped. 

Syntax:

drop()

Example 1: 

The sample database is as follows: 

👁 Image
 

Output: 

👁 Image

Example 2: If collection does not exist. 
 

Output:

Not Present
Comment
Article Tags: