Book description
Learn how to leverage MongoDB with your Python applications, using the hands-on recipes in this book. You get complete code samples for tasks such as making fast geo queries for location-based apps, efficiently indexing your user documents for social-graph lookups, and many other scenarios.
This guide explains the basics of the document-oriented database and shows you how to set up a Python environment with it. Learn how to read and write to MongoDB, apply idiomatic MongoDB and Python patterns, and use the database with several popular Python web frameworks. You’ll discover how to model your data, write effective queries, and avoid concurrency problems such as race conditions and deadlocks.
The recipes will help you:
- Read, write, count, and sort documents in a MongoDB collection
- Learn how to use the rich MongoDB query language
- Maintain data integrity in replicated/distributed MongoDB environments
- Use embedding to efficiently model your data without joins
- Code defensively to avoid keyerrors and other bugs
- Apply atomic operations to update game scores, billing systems, and more with the fast accounting pattern
- Use MongoDB with the Pylons 1.x, Django, and Pyramid web frameworks
Table of contents
- A Note Regarding Supplemental Files
- Preface
- 1. Getting Started
-
2. Reading and Writing to MongoDB with
Python
- Connecting to MongoDB with Python
- Getting a Database Handle
- Inserting a Document into a Collection
- Write to a Collection Safely and Synchronously
- Guaranteeing Writes to Multiple Database Nodes
- Introduction to MongoDB Query Language
- Reading, Counting, and Sorting Documents in a Collection
- Updating Documents in a Collection
- Deleting Documents from a Collection
- MongoDB Query Operators
- MongoDB Update Modifiers
-
3. Common MongoDB and Python
Patterns
- A Uniquely Document-Oriented Pattern: Embedding
- Fast Lookups: Using Indexes with MongoDB
- Location-based Apps with MongoDB: GeoSpatial Indexing
- Code Defensively to Avoid KeyErrors and Other Bugs
- Update-or-Insert: Upserts in MongoDB
- Atomic Read-Write-Modify: MongoDB’s findAndModify
- Fast Accounting Pattern
- 4. MongoDB with Web Frameworks
- About the Author
- Copyright
Product information
- Title: MongoDB and Python
- Author(s):
- Release date: September 2011
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781449310370
You might also like
book
Designing Data-Intensive Applications
Data is at the center of many challenges in system design today. Difficult issues need to …
book
Tiny Python Projects
The projects are tiny, but the rewards are big: each chapter in Tiny Python Projects challenges …
book
Head First Design Patterns, 2nd Edition
You know you don’t want to reinvent the wheel, so you look to design patterns—the lessons …
book
Software Engineering at Google
Today, software engineers need to know not only how to program effectively but also how to …