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.
Querying a MongoDB collection in Python applications
From the course: MongoDB Python Developer Associate Cert Prep
Querying a MongoDB collection in Python applications
- Hello. In this video you'll learn how to query a MongoDB collection by using the PyMongo driver. There are two methods that we can use to query in MongoDB. Find_one is used to return a single document that matches a query. Find is used to return all documents that match a query. Let's start with an example of the most basic type of query that can be performed in MongoDB, which is find_one. Find_one returns a single document that matches a query, or it returns none if there are no matches. Find_one is useful in cases where we know there is only one matching document, or if we're only interested in the first match. In this example we'll work with a database named bank that contains an accounts collection. Let's say we want to retrieve the document from the accounts collection that matches this _id value. It's appropriate to use find_one for this query because there can only be one document in a collection that matches any…
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)
-
-
-
-
-
-
-