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.2.tar.gz (86.4 kB view details)

Uploaded Source

Built Distributions

pymongo-0.15.2-py2.6-win32.egg (126.5 kB view details)

Uploaded Source

pymongo-0.15.2-py2.6-macosx-10.6-universal.egg (141.1 kB view details)

Uploaded Source

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

Uploaded Source

pymongo-0.15.2-py2.5-macosx-10.6-i386.egg (126.2 kB view details)

Uploaded Source

pymongo-0.15.2-py2.4-macosx-10.6-i386.egg (127.7 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for pymongo-0.15.2.tar.gz
Algorithm Hash digest
SHA256 117538b9482f373d21242ba8656c60a1598a2d333c7748b5131a91dde3266147
MD5 d8329be30652a2a15f0a22fc515bf3fb
BLAKE2b-256 7c9c44993c58b5a93d0ebc3c65fdb1bac4efa5349efe27fd28f2ca8554c8d129

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.15.2-py2.6-win32.egg
Algorithm Hash digest
SHA256 6dea57728e5d75d781e6a792bc7874e04d2699ca0e0d42cfc25991faaf54cca0
MD5 81b3b7d11fda80cbf51e65900c8a651d
BLAKE2b-256 0c690d6b59e2baa4b646366eb7c4a0a631496fbc993be7bf4e0a7ba9de7eaed1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.15.2-py2.6-macosx-10.6-universal.egg
Algorithm Hash digest
SHA256 c05327142e71834567fa40cdd4365139020b02509e31019a2f17600a2fa788e7
MD5 80c86036fee93decc8c08653deccbdf7
BLAKE2b-256 f167598e7d2e3d0934117da8d4534dc489f7b695ba8b8eb3008feed7db80b676

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.15.2-py2.5-win32.egg
Algorithm Hash digest
SHA256 bc6c7302791e66376ab94d5c7bc2104c4afd584741b3a9b5e1f526fd74e3cf58
MD5 01fbb8517c5969ebd4f6f9209a50df5d
BLAKE2b-256 35e61551d05ffca3f7578972d2eeaeeaeffd808674592d3856feca705c041b21

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.15.2-py2.5-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 0cbce9997e59a16054c6300a06c3fc2c3e1625673eb84008da8afba1356b890f
MD5 9c07d0db898599a203682615495d13d8
BLAKE2b-256 3a38d81803a081a664bba440afb766b318f9b72202872d609a6a565a8369d45f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.15.2-py2.4-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 99fd743e17c6064a65d2fdb6fba8d9ee75d464dd250911faa2bc5907d5fef115
MD5 039f2c1b0173a867b6cc3045d3f1a064
BLAKE2b-256 be92646b248c55795a93ad8e624b95c5da7c9a428cdd11c4dccf47584ee83aba

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