Sometimes, you just need to delete a record. That's easy with the delete_one()
method.
As we've seen in the previous recipes, the first thing to do is to create a filter to find the record to delete.
from pymongo import MongoClient client = MongoClient('localhost', 27017) db = client.pythonbicookbook customers = db.customers result = customers.delete_one({ 'first_name': 'Bob', 'last_name': 'Smith' }) print(result.deleted_count)