pymongo 3.8.0


pip install pymongo==3.8.0

Project Links

Meta
Author: Bernie Hackett

Classifiers

Development Status
  • 5 - Production/Stable

Intended Audience
  • Developers

License
  • OSI Approved :: Apache Software License

Operating System
  • MacOS :: MacOS X
  • Microsoft :: Windows
  • POSIX

Programming Language
  • Python :: 2
  • Python :: 2.7
  • Python :: 3
  • Python :: 3.4
  • Python :: 3.5
  • Python :: 3.6
  • Python :: 3.7
  • Python :: Implementation :: CPython
  • Python :: Implementation :: PyPy

Topic
  • Database
Info:

See the mongo site for more information. See GitHub for the latest source.

Author:

Mike Dirolf

Maintainer:

Bernie Hackett <bernie@mongodb.com>

About

The PyMongo distribution contains tools for interacting with MongoDB database from Python. The bson package is an implementation of the BSON format for Python. The pymongo package is a native Python driver for MongoDB. The gridfs package is a gridfs implementation on top of pymongo.

PyMongo supports MongoDB 2.6, 3.0, 3.2, 3.4, 3.6 and 4.0.

Support / Feedback

For issues with, questions about, or feedback for PyMongo, please look into our support channels. Please do not email any of the PyMongo developers directly with issues or questions - you’re more likely to get an answer on the mongodb-user list on Google Groups.

Bugs / Feature Requests

Think you’ve found a bug? Want to see a new feature in PyMongo? Please open a case in our issue management tool, JIRA:

Bug reports in JIRA for all driver projects (i.e. PYTHON, CSHARP, JAVA) and the Core Server (i.e. SERVER) project are public.

How To Ask For Help

Please include all of the following information when opening an issue:

  • Detailed steps to reproduce the problem, including full traceback, if possible.

  • The exact python version used, with patch level:

    $ python -c "import sys; print(sys.version)"
  • The exact version of PyMongo used, with patch level:

    $ python -c "import pymongo; print(pymongo.version); print(pymongo.has_c())"
  • The operating system and version (e.g. Windows 7, OSX 10.8, …)

  • Web framework or asynchronous network library used, if any, with version (e.g. Django 1.7, mod_wsgi 4.3.0, gevent 1.0.1, Tornado 4.0.2, …)

Security Vulnerabilities

If you’ve identified a security vulnerability in a driver or any other MongoDB project, please report it according to the instructions here.

Installation

PyMongo can be installed with pip:

$ python -m pip install pymongo

Or easy_install from setuptools:

$ python -m easy_install pymongo

You can also download the project source and do:

$ python setup.py install

Do not install the “bson” package from pypi. PyMongo comes with its own bson package; doing “easy_install bson” installs a third-party package that is incompatible with PyMongo.

Dependencies

PyMongo supports CPython 2.7, 3.4+, PyPy, and PyPy3.5+.

Optional dependencies:

GSSAPI authentication requires pykerberos on Unix or WinKerberos on Windows. The correct dependency can be installed automatically along with PyMongo:

$ python -m pip install pymongo[gssapi]

Support for mongodb+srv:// URIs requires dnspython:

$ python -m pip install pymongo[srv]

TLS / SSL support may require ipaddress and certifi or wincertstore depending on the Python version in use. The necessary dependencies can be installed along with PyMongo:

$ python -m pip install pymongo[tls]

Wire protocol compression with snappy requires python-snappy:

$ python -m pip install pymongo[snappy]

You can install all dependencies automatically with the following command:

$ python -m pip install pymongo[snappy,gssapi,srv,tls]

Other optional packages:

  • backports.pbkdf2, improves authentication performance with SCRAM-SHA-1 and SCRAM-SHA-256. It especially improves performance on Python versions older than 2.7.8.

  • monotonic adds support for a monotonic clock, which improves reliability in environments where clock adjustments are frequent. Not needed in Python 3.

Additional dependencies are:

  • (to generate documentation) sphinx

Examples

Here’s a basic example (for more see the examples section of the docs):

>>> import pymongo
>>> client = pymongo.MongoClient("localhost", 27017)
>>> db = client.test
>>> db.name
u'test'
>>> db.my_collection
Collection(Database(MongoClient('localhost', 27017), u'test'), u'my_collection')
>>> db.my_collection.insert_one({"x": 10}).inserted_id
ObjectId('4aba15ebe23f6b53b0000000')
>>> db.my_collection.insert_one({"x": 8}).inserted_id
ObjectId('4aba160ee23f6b543e000000')
>>> db.my_collection.insert_one({"x": 11}).inserted_id
ObjectId('4aba160ee23f6b543e000002')
>>> db.my_collection.find_one()
{u'x': 10, u'_id': ObjectId('4aba15ebe23f6b53b0000000')}
>>> for item in db.my_collection.find():
...     print(item["x"])
...
10
8
11
>>> db.my_collection.create_index("x")
u'x_1'
>>> for item in db.my_collection.find().sort("x", pymongo.ASCENDING):
...     print(item["x"])
...
8
10
11
>>> [item["x"] for item in db.my_collection.find().limit(2).skip(1)]
[8, 11]

Documentation

You will need sphinx installed to generate the documentation. Documentation can be generated by running python setup.py doc. Generated documentation can be found in the doc/build/html/ directory.

Testing

The easiest way to run the tests is to run python setup.py test in the root of the distribution.

To verify that PyMongo works with Gevent’s monkey-patching:

$ python green_framework_test.py gevent

Or with Eventlet’s:

$ python green_framework_test.py eventlet
4.13.0 May 14, 2025
4.13.0.dev0 May 14, 2025
4.12.1 Apr 29, 2025
4.12.0 Apr 08, 2025
4.11.3 Mar 18, 2025
4.11.2 Mar 03, 2025
4.11.1 Feb 10, 2025
4.11 Jan 28, 2025
4.10.1 Oct 01, 2024
4.10.0 Oct 01, 2024
4.9.2 Oct 02, 2024
4.9.1 Sep 18, 2024
4.9 Sep 18, 2024
4.8.0 Jun 26, 2024
4.8.0b0 Jun 25, 2024
4.7.3 Jun 04, 2024
4.7.2 May 07, 2024
4.7.1 Apr 30, 2024
4.7.0 Apr 24, 2024
4.6.3 Mar 28, 2024
4.6.2 Feb 21, 2024
4.6.1 Nov 29, 2023
4.6.0 Nov 01, 2023
4.5.0 Aug 22, 2023
4.4.1 Jul 13, 2023
4.4.0 Jun 21, 2023
4.4.0b0 Jan 25, 2023
4.3.3 Nov 17, 2022
4.3.2 Oct 18, 2022
4.2.0 Jul 20, 2022
4.1.1 Apr 13, 2022
4.1.0 Apr 04, 2022
4.0.2 Mar 03, 2022
4.0.1 Dec 07, 2021
4.0 Nov 29, 2021
3.13.0 Nov 01, 2022
3.12.3 Dec 07, 2021
3.12.2 Nov 29, 2021
3.12.1 Oct 19, 2021
3.12.0 Jul 13, 2021
3.11.4 May 04, 2021
3.11.3 Feb 03, 2021
3.11.2 Dec 02, 2020
3.11.1 Nov 17, 2020
3.11.0 Jul 30, 2020
3.10.1 Jan 08, 2020
3.10.0 Dec 10, 2019
3.9.0 Aug 14, 2019
3.8.0 Apr 22, 2019
3.7.2 Oct 10, 2018
3.7.1 Jul 16, 2018
3.7.0 Jun 26, 2018
3.6.1 Mar 01, 2018
3.6.0 Dec 05, 2017
3.5.1 Aug 23, 2017
3.5.0 Aug 08, 2017
3.4.0 Nov 29, 2016
3.3.1 Oct 27, 2016
3.3.0 Jul 12, 2016
3.2.2 Mar 15, 2016
3.2.1 Feb 02, 2016
3.2 Dec 08, 2015
3.1.1 Nov 18, 2015
3.1 Nov 02, 2015
3.0.3 Jul 01, 2015
3.0.2 May 12, 2015
3.0.1 Apr 21, 2015
3.0 Apr 07, 2015
2.9.5 Jun 30, 2017
2.9.4 Sep 30, 2016
2.9.3 Mar 15, 2016
2.9.2 Feb 01, 2016
2.9.1 Nov 17, 2015
2.9 Sep 30, 2015
2.8.1 May 11, 2015
2.8 Jan 28, 2015
2.7.2 Jul 29, 2014
2.7.1 May 23, 2014
2.7 Apr 03, 2014
2.6.3 Oct 11, 2013
2.6.2 Sep 06, 2013
2.6.1 Sep 04, 2013
2.6 Aug 19, 2013
2.5.2 Jun 01, 2013
2.5.1 May 13, 2013
2.5 Mar 22, 2013
2.4.2 Jan 24, 2013
2.4.1 Dec 06, 2012
2.4 Nov 27, 2012
2.3 Aug 29, 2012
2.2.1 Jul 06, 2012
2.2 Apr 30, 2012
2.1.1 Jan 05, 2012
2.1 Dec 07, 2011
2.0.1 Aug 16, 2011
2.0 Aug 06, 2011
1.11 May 06, 2011
1.10.1 Apr 07, 2011
1.10 Mar 30, 2011
1.9 Sep 28, 2010
1.8.1 Aug 13, 2010
1.8 Aug 05, 2010
1.7 Jun 17, 2010
1.6 Apr 14, 2010
1.5.2 Mar 31, 2010
1.5.1 Mar 17, 2010
1.5 Mar 10, 2010
1.4 Jan 27, 2010
1.3 Dec 16, 2009
1.2.1 Dec 10, 2009
1.2 Dec 09, 2009
1.1.2 Nov 23, 2009
1.1.1 Nov 14, 2009
1.1 Oct 21, 2009
1.0 Sep 30, 2009
0.16 Sep 16, 2009
0.15.2 Sep 09, 2009
0.15.1 Sep 03, 2009
0.15 Aug 26, 2009
0.14.2 Aug 24, 2009
0.14.1 Aug 21, 2009
0.14 Aug 19, 2009
0.13 Jul 29, 2009
0.12 Jul 08, 2009
0.11.3 Jun 18, 2009
0.11.2 Jun 08, 2009
0.11.1 Jun 04, 2009
0.11 Jun 03, 2009
0.10.3 May 27, 2009
0.10.2 May 22, 2009
0.10.1 May 18, 2009
0.10 May 14, 2009
0.9.7 May 13, 2009
0.9.6 May 08, 2009
0.9.5 Apr 15, 2009
0.9.4 Apr 15, 2009
0.9.3 Apr 03, 2009
0.9.2 Mar 26, 2009
0.9.1 Mar 18, 2009
0.9 Mar 17, 2009
0.8.1 Feb 27, 2009
0.8 Feb 20, 2009
0.7.2 Feb 20, 2009
0.7.1 Feb 20, 2009
0.7 Feb 17, 2009
0.6 Feb 11, 2009
0.5.3rc0 Feb 09, 2009
0.5.2rc0 Feb 06, 2009
0.5.1rc0 Feb 06, 2009
0.5rc0 Feb 05, 2009
0.4rc0 Feb 05, 2009
0.3.1rc0 Feb 03, 2009
0.3rc0 Jan 30, 2009
0.2rc0 Jan 27, 2009
0.1.2rc0 Jan 23, 2009
0.1.1rc0 Jan 23, 2009
0.1rc0 Jan 22, 2009
0.0rc0 Jan 22, 2009

Wheel compatibility matrix

Platform CPython 2.7 CPython 3.4 CPython 3.5 CPython 3.6 CPython 3.7 CPython (wide) 2.7
macosx_10_13_intel
macosx_10_6_intel
macosx_10_9_x86_64
manylinux1_i686
manylinux1_x86_64
win32
win_amd64

Files in release

Extras:
Dependencies: