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
Chapter 1 Getting Started
Finding Reference Documentation
Setting up a Python Environment with MongoDB
Chapter 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
Chapter 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
Niall O'Higgins is a software consultant specializing in mobile, tablet and cloud computing. His accomplishments include designing and implementing numerous mobile and web platforms using MongoDB, Python and Pylons/Django/Pyramid. Prior to starting his consulting business, he was a software engineer at Metaweb Technologies, where he worked on Freebase.com (now owned by Google). He is the founder and organizer of both the San Francisco Python Web Technology Meet-up, PyWebSF and the Bay Area Tablet Computing Group, We Have Tablets. He has published quite a bit of Open Source software - contributing to OpenBSD and Pyramid among others - and frequently speaks at conferences and events.
I needed a database for the Web App I'm making and thought a document store would be nice, because it makes it really easy to look up attributes of objects I store in it. Given I've been hearing good things about MongoDB the past year, I decided to finally give it a serious try. So I picked up MongoDB and Python: Patterns and processes for the popular document-oriented database hoping to pick up some best practices.
Sadly the book is really basic, so while it was helpful to get the hang of the syntax, I could have learned that from their documentation. They reuse a lot of code between examples, making them rather repetitive and don't really show off any examples that show the benefits of having a document store like MongoDB. Furthermore, the book is only 53 pages, which really doesn't justify the price. So I'd skip this one and just go for the online documentation and experimenting yourself.
Bottom Line No, I would not recommend this to a friend
Niall O'Higgins has skilfully and simply bridged the divide between uber-nerd and regular human. This book was a God-send for me and answered all the big questions I had, particularly regarding PyMongo, as well as clearly demonstrating ways to start building a solid PyMongo application. Well done!
Bottom Line Yes, I would recommend this to a friend