Python, the top programming language for data science, and MongoDB, with its flexible and dynamic schema, are a fantastic match for building modern web applications, JSON APIs, and data processors, just to name a few. MongoDB has a native Python driver and a team of engineers dedicated to making sure MongoDB and Python work together flawlessly.
Table of Contents
What is Python?
Python, the Swiss Army knife of today’s dynamically typed languages, has comprehensive support for common data manipulation and processing tasks, which makes it one of the best programming languages for data science and web development. Python’s native dictionary and list data types make it second only to JavaScript for manipulating JSON documents — and well-suited to working with BSON. PyMongo, the standard MongoDB driver library for Python, is easy to use and offers an intuitive API for accessing databases, collections, and documents.
Objects retrieved from MongoDB through PyMongo are compatible with dictionaries and lists, so we can easily manipulate, iterate, and print them.
How MongoDB stores data
MongoDB stores data in JSON-like documents:
Python dictionaries look like:
Read on for an overview of how to get started and deliver on the potential of this powerful combination.
Prerequisites
Download and install Python on your machine. To confirm if your installation is right, type python --version in your command line terminal. You should get something similar to:
You can follow the python MongoDB examples in this tutorial even if you are new to Python.