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 the Mongo database from Python. The pymongo package is a native Python driver for the Mongo database. 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 has been tested on Python 2.x, where x >= 3. On Python 2.3 the optional C extension will not be built. This will negatively affect performance, but everything should still work.

Additional dependencies are:

  • ElementTree (this is included with Python >= 2.5)

  • (to generate documentation) epydoc

  • (to auto-discover tests) nose

Examples

Here’s a basic example (for more see the examples/ directory):

>>> from pymongo.connection import Connection
>>> connection = 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('D\x87\xdd\xe8\xd6\x0f\x89\xfc\xab\x06\xac\x8e')
>>> db.my_collection.save({"x": 8})
ObjectId('\xde\x0b\xec^\xdc\x11`\x12\xf8\xeb/\xcf')
>>> db.my_collection.save({"x": 11})
ObjectId('\t6\xc6\x07\xb3\xfc\x87\xc4\x82\x04\x0f\\')
>>> db.my_collection.find_one()
{u'x': 10, u'_id': ObjectId('D\x87\xdd\xe8\xd6\x0f\x89\xfc\xab\x06\xac\x8e')}
>>> for item in db.my_collection.find():
...     print item["x"]
...
10
8
11
>>> db.my_collection.create_index("x")
u'x_1'
>>> from pymongo import ASCENDING
>>> for item in db.my_collection.find().sort("x", 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 epydoc installed to generate the documentation. Documentation can be generated by running python setup.py doc. Generated documentation can be found in the doc/ 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.

Credits

Thanks to (in no particular order) (if you belong here and are missing please let us know):

  • moe at mbox dot bz: turn off nagle

  • Michael Stephens (mikejs): seek and tell for read mode GridFile

  • Joakim Sernbrant (serbaut): fix decref bug in tuple encoder, hex __repr__ and __str__ for ObjectId

  • Alexander Artemenko (svetlyak40wt): fix spurious errors in thread test

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

pymongo-0.15.1.tar.gz (86.5 kB view details)

Uploaded Source

Built Distributions

pymongo-0.15.1-py2.6-win32.egg (126.7 kB view details)

Uploaded Source

pymongo-0.15.1-py2.6-macosx-10.6-universal.egg (141.3 kB view details)

Uploaded Source

pymongo-0.15.1-py2.5-win32.egg (125.9 kB view details)

Uploaded Source

pymongo-0.15.1-py2.5-macosx-10.6-i386.egg (126.4 kB view details)

Uploaded Source

pymongo-0.15.1-py2.4-macosx-10.6-i386.egg (127.9 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for pymongo-0.15.1.tar.gz
Algorithm Hash digest
SHA256 fb1cd04329f31d7b7c1e0066540087fe0833238eb83d4d9c35ab1975b335736d
MD5 4da9e562248b44cd9193571dae259a1c
BLAKE2b-256 0b9069cac8a42ce32416fc9f914c3f6760efd5ff427be658a42974b31413010f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.15.1-py2.6-win32.egg
Algorithm Hash digest
SHA256 7c66eb06aff8c154b751c1d294f1dec51aa1e94189d0cad191028a982dacaf18
MD5 457776afa99aee6e3862a82b741f9323
BLAKE2b-256 302083b2ede2569ed06f0dbcdc9ab920359ae18ce77adedb0763a88c78b69aa0

See more details on using hashes here.

File details

Details for the file pymongo-0.15.1-py2.6-macosx-10.6-universal.egg.

File metadata

File hashes

Hashes for pymongo-0.15.1-py2.6-macosx-10.6-universal.egg
Algorithm Hash digest
SHA256 8a59c46066a0b267c8a2dcab7a02cec41e80f3652004e3b7e7a26719ce4961d4
MD5 0585aab30d631720a3c63afb39bcdd67
BLAKE2b-256 b135f96d8cbbde0917654fbe471dba75c70f64d1ee81c0f2e625d6afcb35af30

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.15.1-py2.5-win32.egg
Algorithm Hash digest
SHA256 100ad127244b6c255daed43b26bd2a36b64cb13b332de151aad4b2e5c10706e3
MD5 963b38b998967492a2ae60db486005e7
BLAKE2b-256 57f4b9912034766673d94820a98c0a10e25ff20d5dd6cbdc18480cde61e40fe7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.15.1-py2.5-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 c19eb9707875ac918d81d51dd75d92f95f077da5fa8840461943c61701240073
MD5 64f69910851480ec94bd8e9e6d9e8405
BLAKE2b-256 27c695585e9d473a2e2404202d06ecf02a033afcc5d4217d64ef634a671d7414

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.15.1-py2.4-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 570c76fb9ebf111ab624445acd3c54bd9df8092836da3426c1e7e914580b1fff
MD5 39a5547612b29e54943e01e81d273322
BLAKE2b-256 e17b9c18f32534322cc4d4c7e66db9d304c0f2c064cf45c1048ab2219ae14a7a

See more details on using hashes here.

Supported by

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