MongoDB with Async Python
This course will teach you how to use MongoDB and document databases to build simpler and faster data-driven applications.
We start by explaining the origin and major concepts of NoSQL and document databases. You then learn how to work with MongoDB from its native shell as well as many of the CLI and GUI management tools.
Many MongoDB courses stop there. This course is meant to be a practical end-to-end coverage of MongoDB. We go beyond scratching the surface by covering real-world topics.
You'll see how to use Beanie (a popular ODM for MongoDB - think ORM for NoSQL) to map classes to MongoDB. Beanie is based on state-of-the-art Python technologies such as Pydantic and Python's async and await.
In this code-based and hands-on, demo-driven course, we will build some simple example apps using Beanie. Then we'll move on to modeling real PyPI data with 100,000s of records in MongoDB. Once we have our Python code working with the PyPI data, we'll build out a full FastAPI API around the data showing the smooth integration of Beanie and async MongoDB within FastAPI.
After we master working with MongoDB from Python, we'll turn our attention to performance. We take a large database with millions of data points and make it run hundreds of times faster than you get out-of-the-box with MongoDB. We test our performance changes with both custom Python code and the Locust load testing framework.
We wrap up the course by deploying MongoDB to production Linux servers. There are a few very important steps to getting MongoDB running in production and we'll go step-by-step through this setup.
In the end, you'll be ready to start building and running high-performance, MongoDB-backed, data-driven applications.
More
In this course, you will:
- How document databases, such as MongoDB, work
- Where MongoDB fits in the larger scope of databases used in the world
- How to install and configure MongoDB and several management tools and GUIs
- A basic set of MongoDB's native shell commands and queries
- Foundational technologies such as Pydantic and Python's async and await
- How to design data models with Beanie and Pydantic
- Understand the tradeoffs when modeling data with documents
- Learn when it's a good idea (and when it's a bad one) to embed data within other records
- Use ORM-style programming with MongoDB and Beanie
- Use more efficient "in-place" operations such as addToSet with Beanie
- Design projection classes in Pydantic for improved performance
- How to safely store user accounts (namely passwords) in MongoDB
- To deeply integrate Beanie and MongoDB with FastAPI
- Create complex indexes in MongoDB from Beanie for 1000x performance boosts
- Use indexes to enforce data integrity in MongoDB
- Safely deploy MongoDB in a self-hosted environment within a cloud provider on multiple Linux machines
- Use the load testing framework Locust to probe and test the performance limits of your MongoDB-based web APIs
- And lots more
Watch Online MongoDB with Async Python
# | Title | Duration |
---|---|---|
1 | Introducing the Course | 00:54 |
2 | MongoDB is Loved | 03:06 |
3 | MongoDB is fast | 03:44 |
4 | Python's asyncio | 02:41 |
5 | What is Beanie and What is an ODM? | 04:28 |
6 | Course Topics | 03:44 |
7 | Meet Your Instructor: Michael Kennedy | 01:15 |
8 | Setup Introduction | 02:23 |
9 | Installing MongoDB | 02:14 |
10 | Studio 3T GUI | 01:16 |
11 | Importing PyPI Data | 02:35 |
12 | Verifying the Data with Studio 3T | 02:30 |
13 | Document Dbs introduction | 01:04 |
14 | How Document Databases Work | 03:27 |
15 | Who uses MongoDB? | 03:01 |
16 | Mongo Shell | 02:13 |
17 | A More Complex Query | 01:34 |
18 | And Operators in Queries | 01:09 |
19 | Querying Embedded Data | 01:41 |
20 | Studio 3T: A Better Shell | 02:04 |
21 | Query Operators | 02:55 |
22 | Queries: Logical Operators | 00:50 |
23 | Queries: Projections | 04:24 |
24 | Pydantic Introduction | 00:49 |
25 | A Time of Change for Pydantic | 02:12 |
26 | Get the Plugins | 01:03 |
27 | Built on Pydantic | 04:01 |
28 | Project Setup | 05:11 |
29 | Our First Pydantic Model | 06:20 |
30 | JSON to Pydantic Converter | 05:36 |
31 | Get the Full Story on Pydantic | 00:56 |
32 | Pydantic has a Solid Foundation | 01:19 |
33 | Async introduction | 01:24 |
34 | Async for Speed | 04:07 |
35 | Async for Scalability | 01:02 |
36 | Synchronous Execution Example | 04:02 |
37 | Asynchronous Execution Example | 02:21 |
38 | Skeleton async Program | 08:27 |
39 | Full Concurrency Weather Client | 07:49 |
40 | Beanie Quickstart Intro | 00:45 |
41 | Motor, MongoDB's Async Driver | 01:49 |
42 | Beanie Quickstart: Part 1 Classes | 12:23 |
43 | Beanie Quickstart: Part 2 Connections | 10:43 |
44 | Beanie Quickstart: Part 3 Inserts | 04:02 |
45 | Beanie Quickstart: Part 4 Queries | 08:43 |
46 | Beanie Quickstart: part 5 settings | 05:29 |
47 | Lightning Review of Beanie | 03:13 |
48 | Get the Full Story of Beanie | 00:41 |
49 | Bunnet, the Synchronous Beanie | 01:16 |
50 | Modeling Introduction | 00:58 |
51 | Modeling: Relational vs. Documents | 03:28 |
52 | To Embed or not to Embed? | 05:12 |
53 | What is an Integration Database? | 03:12 |
54 | Looking for More Guidance? | 00:40 |
55 | PyPI Api Introduction | 00:47 |
56 | Recall: Importing the Data | 01:03 |
57 | Review: The Data Model | 05:15 |
58 | Creating the DB Models | 08:35 |
59 | Configuring Collections from Beanie | 02:47 |
60 | Connecting to MongoDB | 04:52 |
61 | CLI Skeleton | 04:39 |
62 | ClI REPL | 01:40 |
63 | Summary Stats | 05:30 |
64 | Recent Packages | 05:05 |
65 | Finding Packages and Releases | 10:14 |
66 | Creating a Release | 07:01 |
67 | Concurrency Safe Create Release | 11:03 |
68 | Creating Users | 05:27 |
69 | Setting the User's Password | 06:45 |
70 | FastAPI Introduction | 01:24 |
71 | FastAPI Skeleton App | 06:10 |
72 | API Endpoints Ready | 08:11 |
73 | Package Details Implementation | 12:07 |
74 | Sometimes API focused models are required | 08:36 |
75 | Stats API | 03:36 |
76 | The Home Page Doesn't Belong in the API Docs | 02:01 |
77 | Static Files: CSS | 10:42 |
78 | Introduction to DB Performance | 00:48 |
79 | Levers and Knobs of MongoDB Performance | 04:38 |
80 | Creating Indexes in the Shell | 02:22 |
81 | Our First Python to MongoDB Index | 08:49 |
82 | Releases Counted in 1ms | 06:40 |
83 | Uniqueness Index for Users | 03:48 |
84 | Projections for Packages | 09:08 |
85 | Concept: Projections in Beanie | 01:11 |
86 | Document Design from a Performance Perspective | 03:52 |
87 | Hosting Introduction | 01:14 |
88 | Don't Do What These Companies Did with MongoDB | 02:09 |
89 | MongoDB as a Service Options | 02:05 |
90 | MongoDB's Security Checklist | 02:12 |
91 | Getting the Server Ready | 03:13 |
92 | Limit Network Access with VPCs and Firewall | 05:36 |
93 | Creating an Encryption Key | 01:18 |
94 | Installing MongoDB | 03:45 |
95 | Configuring MongoDB, Part 1 | 04:40 |
96 | Adding Authentication to MongoDB | 04:40 |
97 | Connecting to Production MongoDB with Python | 05:44 |
98 | Importing Data Introduction for Production MongoDB | 03:06 |
99 | Connecting to a Remote MongoDB | 06:25 |
100 | Testing our Python Code in Production | 06:26 |
101 | Final Comments on Speed | 01:51 |
102 | Load Testing Introduction | 01:08 |
103 | Introducing Locust | 04:21 |
104 | Consider a Real Server Topology | 01:13 |
105 | Running Locust for Max RPS | 10:57 |
106 | Running Locust for Max Users | 09:05 |
107 | Faster Locust Tests | 01:10 |
108 | Finish Line! | 00:42 |
109 | Git the Source Code, Again | 00:30 |
110 | Final Review | 06:11 |
111 | Stay in Touch | 01:02 |