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
>>> from pymongo import ASCENDING
>>> db.my_collection.create_index("x", ASCENDING)
u'x_1'
>>> 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

This version

0.15

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

Uploaded Source

Built Distributions

pymongo-0.15-py2.6-win32.egg (125.5 kB view details)

Uploaded Source

pymongo-0.15-py2.6-macosx-10.5-i386.egg (124.7 kB view details)

Uploaded Source

pymongo-0.15-py2.5-win32.egg (125.4 kB view details)

Uploaded Source

pymongo-0.15-py2.5-macosx-10.5-i386.egg (124.9 kB view details)

Uploaded Source

pymongo-0.15-py2.4-macosx-10.5-i386.egg (126.2 kB view details)

Uploaded Source

pymongo-0.15-py2.3-macosx-10.5-i386.egg (379.4 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for pymongo-0.15.tar.gz
Algorithm Hash digest
SHA256 82ed26a03762797a14e33e33896fa7003a96aaca677d902509a53adeea41c787
MD5 d9b8e28dcd735cadab1c0d3664d90988
BLAKE2b-256 e1e1a741476b242af27f985021127d5de610cc8ac852426dd1a8d4076bc1d45c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.15-py2.6-win32.egg
Algorithm Hash digest
SHA256 ee2be3920cc1b0c8d93090b04810f8a4e94514d74bc929775a52faa796a766b5
MD5 77bee679d96a399433c2c5866178bea3
BLAKE2b-256 6638c8793024ea7a34e33716d19f71e138ee0f369c7449e0cf13f67ff0910820

See more details on using hashes here.

File details

Details for the file pymongo-0.15-py2.6-macosx-10.5-i386.egg.

File metadata

File hashes

Hashes for pymongo-0.15-py2.6-macosx-10.5-i386.egg
Algorithm Hash digest
SHA256 77e46825be8ff54064e93eeb2196ef06c843754b1e966b32ed3e3db955dfed7c
MD5 99d613dbe9ebda2ed53d003c7db4e325
BLAKE2b-256 9c34a0eb328fc4032d4098f161a6c499264898e1a1afde7143914d4f0f83652b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.15-py2.5-win32.egg
Algorithm Hash digest
SHA256 6accb7a6ebb084342c1e7c939f2f70844d1045638cd29eee850819c8bb19d5fb
MD5 9da1dfb624a77e8b562d8f46e1500ad7
BLAKE2b-256 34328f271d00f033162aaea460ba05abe382cf09f56e84033b37c0012a17ae2f

See more details on using hashes here.

File details

Details for the file pymongo-0.15-py2.5-macosx-10.5-i386.egg.

File metadata

File hashes

Hashes for pymongo-0.15-py2.5-macosx-10.5-i386.egg
Algorithm Hash digest
SHA256 5d285b9e90d2576cc85f6bf3d45d2f02ffb5b90cc8f3561cf2216e803f18efcf
MD5 22110ffbd970c2fbd5aa643b459e231c
BLAKE2b-256 2dd7c7f17c16626cbf52ae111a0b3d26783e2c55a3c2761eaa563d9e73dc217a

See more details on using hashes here.

File details

Details for the file pymongo-0.15-py2.4-macosx-10.5-i386.egg.

File metadata

File hashes

Hashes for pymongo-0.15-py2.4-macosx-10.5-i386.egg
Algorithm Hash digest
SHA256 3ee43f7d4cdb1b840d9586dc8e955064a26a7e18508f526d67b42d344b9dd91b
MD5 d982a3a3408189dac1f4bf3564422040
BLAKE2b-256 a8ad826648c479176dfb7f53e57b924e148cb015dcb47a568be07eb32e373604

See more details on using hashes here.

File details

Details for the file pymongo-0.15-py2.3-macosx-10.5-i386.egg.

File metadata

File hashes

Hashes for pymongo-0.15-py2.3-macosx-10.5-i386.egg
Algorithm Hash digest
SHA256 00229caf34696be32f5f3ae419489c72e17019a52fd2ce69cb2225233fcb5249
MD5 85d27326985481fd8f3e4870ebe44921
BLAKE2b-256 f5f0f7ba3d4272e8f5df5f65d1ce96caae85d13af4b20f598cc97910fd36c9d7

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