Permalink
Fetching contributors…
Cannot retrieve contributors at this time
400 lines (297 sloc) 8.81 KB
.. _python-language-center:
======================
Python MongoDB Drivers
======================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: twocols
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 <http://api.mongodb.com/python/current/tutorial.html>`_.
Python Driver
-------------
**PyMongo** is the recommended way to work with MongoDB from Python.
- `Installation <http://api.mongodb.com/python/current/installation.html>`_
- `Tutorial <http://api.mongodb.com/python/current/tutorial.html>`__
- `API Documentation <http://api.mongodb.com/python/current/api/index.html>`_
- `Changelog <http://api.mongodb.com/python/current/changelog.html>`__
- `Source Code <https://github.com/mongodb/mongo-python-driver>`__
Python Driver Compatibility
~~~~~~~~~~~~~~~~~~~~~~~~~~~
MongoDB Compatibility
`````````````````````
.. include:: /includes/extracts/python-driver-compatibility-matrix-mongodb.rst
.. list-table::
:header-rows: 1
:stub-columns: 1
:class: compatibility
* - Python Driver
- MongoDB 2.4
- MongoDB 2.6
- MongoDB 3.0
- MongoDB 3.2
- MongoDB 3.4
* - 3.4
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
* - 3.3
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
-
* - 3.2
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
-
* - 2.9
- |checkmark|
- |checkmark|
- |checkmark|
-
-
.. include:: /includes/extracts/python-driver-compatibility-full-mongodb.rst
.. include:: /includes/older-server-versions-unsupported.rst
Language Compatibility
``````````````````````
.. include:: /includes/extracts/python-driver-compatibility-matrix-language.rst
.. IMPORTANT: If you're updating this table, you also probably need to
update the table on /drivers/driver-compatibility-reference, which
includes all of the driver versions
Python 2 Compatibility
######################
.. list-table::
:header-rows: 1
:stub-columns: 1
:class: compatibility
:name: Python2 Compatibility
* - Python Driver
- Python 2.4
- Python 2.5, Jython 2.5
- Python 2.6
- Python 2.7, PyPy
* - 3.4
-
-
- |checkmark|
- |checkmark|
* - 3.3
-
-
- |checkmark|
- |checkmark|
* - 3.2
-
-
- |checkmark|
- |checkmark|
* - 2.9
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
Python 3 Compatibility
######################
.. list-table::
:header-rows: 1
:stub-columns: 1
:class: compatibility-large
:name: Python3 Compatibility
* - Python Driver
- Python 3.1
- Python 3.2
- PyPy3
- Python 3.3
- Python 3.4
- Python 3.5
* - 3.4
-
-
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
* - 3.3
-
-
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
* - 3.2
-
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
* - 2.9
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
.. include:: /includes/extracts/python-driver-compatibility-full-language.rst
.. include:: /includes/unicode-checkmark.rst
.. note::
- Jython 2.5 is a Python 2.5-compatible alternative interpreter.
- PyPy is a Python 2.7 and 3.2-compatible alternative interpreter.
.. _python-async-driver:
Async Driver
------------
**Motor** is the recommended asynchronous Python driver for MongoDB.
It is compatible with `Tornado <http://www.tornadoweb.org/>`_ and
`asyncio <https://docs.python.org/3/library/asyncio.html>`_.
- `Documentation <http://motor.readthedocs.org/>`_
- `Tutorial <http://motor.readthedocs.org/en/stable/tutorial.html>`_
- `Changelog <http://motor.readthedocs.org/en/stable/changelog.html>`__
- `Source Code <https://github.com/mongodb/motor/>`__
Articles About Motor
~~~~~~~~~~~~~~~~~~~~
- `Porting From PyMongo To Motor <http://emptysqua.re/blog/porting-from-pymongo-to-motor/>`_
- `Refactoring Tornado Coroutines <http://emptysqua.re/blog/refactoring-tornado-coroutines/>`_
- `All Motor articles on A. Jesse Jiryu Davis's blog <http://emptysqua.re/blog/category/motor/>`_
Motor Compatibility
~~~~~~~~~~~~~~~~~~~
MongoDB Compatibility
`````````````````````
.. include:: /includes/extracts/motor-driver-compatibility-matrix-language.rst
.. list-table::
:header-rows: 1
:stub-columns: 1
:class: compatibility
* - Motor Driver
- MongoDB 2.4
- MongoDB 2.6
- MongoDB 3.0
- MongoDB 3.2
- MongoDB 3.4
* - 1.0
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
* - 0.7
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
-
* - 0.4
- |checkmark|
- |checkmark|
- |checkmark|
-
-
* - 0.3
- |checkmark|
- |checkmark|
-
-
-
- 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
.. include:: /includes/extracts/motor-driver-compatibility-full-mongodb.rst
.. include:: /includes/older-server-versions-unsupported.rst
Language Compatibility
``````````````````````
.. include:: /includes/extracts/motor-driver-compatibility-matrix-language.rst
.. list-table::
:header-rows: 1
:stub-columns: 1
:class: compatibility-large
* - 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
- |checkmark|
- |checkmark|
-
-
- |checkmark|
- |checkmark|
- |checkmark|
* - 0.7
- |checkmark|
- |checkmark|
-
-
- |checkmark|
- |checkmark|
- |checkmark|
* - 0.4
- |checkmark|
- |checkmark|
-
-
- |checkmark|
- |checkmark|
-
* - 0.3
- |checkmark|
- |checkmark|
-
-
- |checkmark|
- |checkmark|
-
- 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
.. include:: /includes/extracts/motor-driver-compatibility-full-language.rst
.. 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.
- `ORM like layers <http://api.mongodb.com/python/current/tools.html#orm-like-layers>`_
Framework Tools
~~~~~~~~~~~~~~~
Several tools and adapters for integration with various Python
frameworks and libraries also exist.
- `Framework Tools <http://api.mongodb.com/python/current/tools.html#framework-tools>`_
Alternative drivers
-------------------
- `Alternative driver list <http://api.mongodb.com/python/current/tools.html#alternative-drivers>`_
Tutorials
---------
- `Python Driver Tutorial <http://api.mongodb.com/python/current/tutorial.html>`__
- `Getting Started with PyMODM <https://pymodm.readthedocs.io/en/latest/getting-started.html>`__
- :gettingstarted:`Getting Started with MongoDB (Python Edition) </python>`
Presentations
-------------
- `MongoDB & Python <https://github.com/behackett/presentations/tree/master/pycon_2012>`_: Workshop materials from PyCon 2012
- `PyCon Poster <http://www.mongodb.com/static/images/pycon-poster.pdf>`_: PyCon 2012
- `Realtime Analytics using MongoDB, Python, Gevent, and ZeroMQ <http://www.mongodb.com/presentations/mongoseattle-2011/realtime-analytics-using-mongodb-python-gevent-and-zeromq>`_: Rick Copeland's presentation from Mongo Seattle (December 2011)
- `MongoDB with Python, Pylons, and Pyramid <https://www.mongodb.com/presentations/mongosf-2011/mongodb-with-python-pylons-pyramid>`_: Niall O'Higgins' presentation from MongoSF (May 2011)
- `Python Development with MongoDB <http://www.mongodb.com/presentations/mongosf-2011/python-development-with-mongodb>`_: Bernie Hackett's presentation from MongoSF (May 2011)
- `Building a Social Graph with MongoDB at Eventbrite
<http://www.mongodb.com/presentations/mongosv-2010/building-social-graph-mongodb-eventbrite>`_:
Brian Zambrano's presentation from MongoSV (December 2010)
- `More Python-related presentations <http://www.mongodb.com/presentations?programming_lang=56>`_