Skip to main content

Python driver for MongoDB <http://www.mongodb.org>

Project description

Info:

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

Author:

Mike Dirolf <mike@10gen.com>

About

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

Installation

If you have setuptools installed you should be able to do easy_install pymongo to install PyMongo. Otherwise you can download the project source and do python setup.py install to install.

Dependencies

The PyMongo distribution is supported and tested on Python 2.x, where x >= 4. PyMongo versions <= 1.3 also supported Python 2.3, but that is no longer supported. If you need to use Python 2.3 please contact us.

Additional dependencies are:

  • (to generate documentation) sphinx

  • (to auto-discover tests) nose

Examples

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

>>> import pymongo
>>> connection = pymongo.Connection("localhost", 27017)
>>> db = connection.test
>>> db.name()
u'test'
>>> db.my_collection
Collection(Database(Connection('localhost', 27017), u'test'), u'my_collection')
>>> db.my_collection.save({"x": 10})
ObjectId('4aba15ebe23f6b53b0000000')
>>> db.my_collection.save({"x": 8})
ObjectId('4aba160ee23f6b543e000000')
>>> db.my_collection.save({"x": 11})
ObjectId('4aba160ee23f6b543e000002')
>>> db.my_collection.find_one()
{u'x': 10, u'_id': ObjectId('4aba160ee23f6b543e000002')}
>>> 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 install nose (easy_install nose) and run nosetests or python setup.py test in the root of the distribution. Tests are located in the test/ directory.

Project details


Release history Release notifications | RSS feed

This version

1.5

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymongo-1.5.tar.gz (121.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pymongo-1.5-py2.6-win32.egg (153.8 kB view details)

Uploaded Egg

pymongo-1.5-py2.6-macosx-10.6-i386.egg (151.5 kB view details)

Uploaded Egg

pymongo-1.5-py2.5-win32.egg (153.4 kB view details)

Uploaded Egg

pymongo-1.5-py2.5-macosx-10.6-i386.egg (151.8 kB view details)

Uploaded Egg

pymongo-1.5-py2.4-macosx-10.6-i386.egg (153.2 kB view details)

Uploaded Egg

File details

Details for the file pymongo-1.5.tar.gz.

File metadata

  • Download URL: pymongo-1.5.tar.gz
  • Upload date:
  • Size: 121.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pymongo-1.5.tar.gz
Algorithm Hash digest
SHA256 d26cdf8a9c16a04d1f0adef868fe49d188f312af0ab5ce1fad170865cda3721a
MD5 c5116d3d859236d91bc0ec2b7ae2b89f
BLAKE2b-256 993638e5f25843f3f7fa37423cc37a2a26b5a7c4d4f623211146bfb7c8d3b848

See more details on using hashes here.

File details

Details for the file pymongo-1.5-py2.6-win32.egg.

File metadata

File hashes

Hashes for pymongo-1.5-py2.6-win32.egg
Algorithm Hash digest
SHA256 2cbd980d07895c98d5782208c7e4e7741c3dde1086448c7b6efebe436cb42f76
MD5 cef89f386c04c47428ea7312099785c8
BLAKE2b-256 fe9417d4852eca6f0cf5b92722c8078aa9bc59bee554997a49517854f81afd4d

See more details on using hashes here.

File details

Details for the file pymongo-1.5-py2.6-macosx-10.6-i386.egg.

File metadata

File hashes

Hashes for pymongo-1.5-py2.6-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 dd45d252ac81c9b92b08f752260833121c2a62f6596dd34a75d0ebef25a78a0e
MD5 0e8364d6303a0b79eeb28d712f6c46b9
BLAKE2b-256 75f9f3f45fbce99706726bf88e4ef276ddd19d14580c71e06675f97141d3c755

See more details on using hashes here.

File details

Details for the file pymongo-1.5-py2.5-win32.egg.

File metadata

File hashes

Hashes for pymongo-1.5-py2.5-win32.egg
Algorithm Hash digest
SHA256 11bf6a911dedf46eeac0b44f29c03def14c6b5bf82040dca00ba8c52892973ab
MD5 7381fb776dac94319f552216b8068600
BLAKE2b-256 14af6404c89af47c3900e41dc04260165a80c3e70a1e9a5fd7f0ac46b052de95

See more details on using hashes here.

File details

Details for the file pymongo-1.5-py2.5-macosx-10.6-i386.egg.

File metadata

File hashes

Hashes for pymongo-1.5-py2.5-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 946f02a64510ff262a7f264609eb1582295bc21237b4d0371a943ac4f6dc966c
MD5 5e6c184fc2de2104ef6d2cc3bac9021e
BLAKE2b-256 c041a71c96fab31ecdcb1de6974e1a14eed95d89a587e9aba3b5dc0bb17d07da

See more details on using hashes here.

File details

Details for the file pymongo-1.5-py2.4-macosx-10.6-i386.egg.

File metadata

File hashes

Hashes for pymongo-1.5-py2.4-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 01ce141f5f8df0bd465031f035eeb4836fc1280c4cb9c0617824b74046e287b3
MD5 482f5d3319bda455de50805bedbd90bf
BLAKE2b-256 623f879f4f0905911b9fdaa91e505bda1cf0f1cb968c37ef2c5e9e87d9eb6245

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page