From the course: MongoDB Python Developer Associate Cert Prep
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Deleting documents in Python applications
From the course: MongoDB Python Developer Associate Cert Prep
Deleting documents in Python applications
- Hello. In this video, you'll learn how to use the delete_one() and delete_many() methods to delete documents in MongoDB by using the PyMongo driver. We can delete a single document from a collection by using the delete_one() method. The delete_one() method accepts a query filter that matches a document that we want to delete. Let's go through an example. We'll work with a database named bank that contains an accounts collection. Let's say that we want to delete the document from the accounts collection that matches this _id value. It's appropriate to use delete_one() for this query because there can only be one document in a collection that matches any given _id value. We've already started a Python file and connected to our Atlas cluster with Mongo client. We have a reference to the bank database and a reference to the accounts collection. First, we create the filter that matches the _id value of the document that we…
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Working with MongoDB documents in Python3m 46s
-
(Locked)
Inserting a document in Python applications3m 20s
-
(Locked)
Querying a MongoDB collection in Python applications3m 38s
-
(Locked)
Updating documents in Python applications4m 21s
-
(Locked)
Deleting documents in Python applications3m 24s
-
(Locked)
Creating MongoDB transactions in Python applications5m 47s
-
(Locked)
MongoDB CRUD operations in Python review1m 13s
-
(Locked)
-
-
-
-
-
-
-