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
Publisher resources
Table of contents
-
MongoDB and Python
- SPECIAL OFFER: Upgrade this ebook with O’Reilly
- 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
- Colophon
- SPECIAL OFFER: Upgrade this ebook with O’Reilly
Product information
- Title: MongoDB and Python
- Author(s):
- Release date: September 2011
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781449317096
You might also like
book
MongoDB Basics
Need a quick and easy to understand introduction to MongoDB and NoSQL databases? MongoDB Basics, from …
book
Data Science Fundamentals for Python and MongoDB
Build the foundational data science skills necessary to work with and better understand complex data science …
book
MongoDB Fundamentals
Learn how to deploy and monitor databases in the cloud, manipulate documents, visualize data, and build …
book
The Definitive Guide to MongoDB: A complete guide to dealing with Big Data using MongoDB, Third Edition
The Definitive Guide to MongoDB, Third Edition, is updated for MongoDB 3 and includes all of …