- MongoDB Drivers >
- Python MongoDB Drivers
Python MongoDB Drivers¶
This is an overview of the available tools for using Python with MongoDB. Those wishing to skip to more detailed discussion should check out the Python Driver Tutorial.
Python Driver¶
PyMongo is the recommended way to work with MongoDB from Python.
Python Driver Compatibility¶
MongoDB Compatibility¶
The following compatibility table specifies the recommended version(s) of the MongoDB Python driver for use with a specific version of MongoDB.
The first column lists the driver version(s).
| Python Driver | MongoDB 2.4 | MongoDB 2.6 | MongoDB 3.0 | MongoDB 3.2 | MongoDB 3.4 |
|---|---|---|---|---|---|
| 3.4 | ✓ | ✓ | ✓ | ✓ | ✓ |
| 3.3 | ✓ | ✓ | ✓ | ✓ | |
| 3.2 | ✓ | ✓ | ✓ | ✓ | |
| 2.9 | ✓ | ✓ | ✓ |
For additional driver versions, see Python Driver MongoDB Compatibility Reference.
The driver does not support older versions of MongoDB.
Language Compatibility¶
The following compatibility table specifies the recommended version(s) of the MongoDB Python driver for use with a specific version of Python.
The first column lists the driver version(s).
Python 2 Compatibility¶
| Python Driver | Python 2.4 | Python 2.5, Jython 2.5 | Python 2.6 | Python 2.7, PyPy |
|---|---|---|---|---|
| 3.4 | ✓ | ✓ | ||
| 3.3 | ✓ | ✓ | ||
| 3.2 | ✓ | ✓ | ||
| 2.9 | ✓ | ✓ | ✓ | ✓ |
Python 3 Compatibility¶
| Python Driver | Python 3.1 | Python 3.2 | PyPy3 | Python 3.3 | Python 3.4 | Python 3.5 |
|---|---|---|---|---|---|---|
| 3.4 | ✓ | ✓ | ✓ | ✓ | ||
| 3.3 | ✓ | ✓ | ✓ | ✓ | ||
| 3.2 | ✓ | ✓ | ✓ | ✓ | ✓ | |
| 2.9 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
For additional driver versions, see Python Driver Language Compatibility Reference.
Note
- Jython 2.5 is a Python 2.5-compatible alternative interpreter.
- PyPy is a Python 2.7 and 3.2-compatible alternative interpreter.
Async Driver¶
Motor is the recommended asynchronous Python driver for MongoDB. It is compatible with Tornado and asyncio.
Articles About Motor¶
Motor Compatibility¶
MongoDB Compatibility¶
The following compatibility table specifies the recommended version(s) of the Motor driver for use with a specific version of Python.
The first column lists the driver version(s).
| Motor Driver | MongoDB 2.4 | MongoDB 2.6 | MongoDB 3.0 | MongoDB 3.2 | MongoDB 3.4 |
|---|---|---|---|---|---|
| 1.0 | ✓ | ✓ | ✓ | ✓ | ✓ |
| 0.7 | ✓ | ✓ | ✓ | ✓ | |
| 0.4 | ✓ | ✓ | ✓ | ||
| 0.3 | ✓ | ✓ |
- Motor 1.0 wraps PyMongo 3.3+
- Motor 0.7 wraps PyMongo >=2.9.4 and <3.0
- Motor 0.4 wraps PyMongo 2.8
- Motor 0.3 wraps PyMongo 2.7.1
For additional driver versions, see Motor Driver MongoDB Compatibility Reference.
The driver does not support older versions of MongoDB.
Language Compatibility¶
The following compatibility table specifies the recommended version(s) of the Motor driver for use with a specific version of Python.
The first column lists the driver version(s).
| Motor Driver | Python 2.6 | Python 2.7 | Python 3.1 | Python 3.2 | Python 3.3 | Python 3.4 | Python 3.5 |
|---|---|---|---|---|---|---|---|
| 1.0 | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| 0.7 | ✓ | ✓ | ✓ | ✓ | ✓ | ||
| 0.4 | ✓ | ✓ | ✓ | ✓ | |||
| 0.3 | ✓ | ✓ | ✓ | ✓ |
- Motor 1.0 wraps PyMongo 3.3+
- Motor 0.7 wraps PyMongo >=2.9.4 and <3.0
- Motor 0.4 wraps PyMongo 2.8
- Motor 0.3 wraps PyMongo 2.7.1
For additional driver versions, see Motor Driver Language Compatibility Reference.
Note
- Motor requires Tornado, and supports the same version of Python as its supported Tornado versions do.
- PyPy is not supported as it runs Motor code slowly.
- Motor does not support Jython or Windows.
Python Tools¶
ORM Like Layers¶
Because MongoDB is so easy to use the basic Python driver is often the best solution for many applications. However, if you need data validation, associations and other high-level data modeling functionality then ORM like layers may be desired.
Framework Tools¶
Several tools and adapters for integration with various Python frameworks and libraries also exist.
Alternative drivers¶
Tutorials¶
Presentations¶
- MongoDB & Python: Workshop materials from PyCon 2012
- PyCon Poster: PyCon 2012
- Realtime Analytics using MongoDB, Python, Gevent, and ZeroMQ: Rick Copeland’s presentation from Mongo Seattle (December 2011)
- MongoDB with Python, Pylons, and Pyramid: Niall O’Higgins’ presentation from MongoSF (May 2011)
- Python Development with MongoDB: Bernie Hackett’s presentation from MongoSF (May 2011)
- Building a Social Graph with MongoDB at Eventbrite: Brian Zambrano’s presentation from MongoSV (December 2010)
- More Python-related presentations