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):

>>> 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 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

    • Performance optimizations for writing large files to GridFS

    • Some updates to the README

    • Fix for ObjectId + multiprocessing

  • Alexander Artemenko (svetlyak40wt):

    • Fix spurious errors in thread test

  • Mathias Stearn (RedBeard0531):

    • Add support for finalize in group()

  • Fajran Iman Rusadi (fajran):

    • Add Debian control files

  • Brad Clements (bkc):

    • A fix for Python 2.3 compatability

  • Andrey Fedorov (andreyf)

    • Added __hash__ methods to DBRef and ObjectId

Project details


Release history Release notifications | RSS feed

This version

1.1

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

Uploaded Source

Built Distributions

pymongo-1.1-py2.6-win32.egg (132.9 kB view details)

Uploaded Source

pymongo-1.1-py2.6-macosx-10.6-i386.egg (132.5 kB view details)

Uploaded Source

pymongo-1.1-py2.5-win32.egg (132.2 kB view details)

Uploaded Source

pymongo-1.1-py2.5-macosx-10.6-i386.egg (132.7 kB view details)

Uploaded Source

pymongo-1.1-py2.4-macosx-10.6-i386.egg (134.1 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for pymongo-1.1.tar.gz
Algorithm Hash digest
SHA256 d88230aa282aaf2ce210b1f144b84602d75563baf43bd9c252af7e335e067ad5
MD5 a1906b69f2f7635fe3fef309acde3af5
BLAKE2b-256 7ad70e2a220ca49f950357c1c8366c9650f647cb06a9ae3d3a8c4f8d601de061

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.1-py2.6-win32.egg
Algorithm Hash digest
SHA256 f3225584a811edc7426d7cef31c74d1f23f7408fd968aefcde8498bdddd10c5f
MD5 181bbaed2c89573a932bf2f41e46c5b5
BLAKE2b-256 cc32921c5318ae78e3f11e51eee92a3eba820ae06637c6e625039ebdd569a91d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.1-py2.6-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 7d16657c920b8e69e0e8440d314c8979bd91191a9da73d6bd1024e6a7a10bba3
MD5 ee598ca2d3919ad7b0411621f66485ad
BLAKE2b-256 76956323b2615f5fb55b9895e869685227ce25f094184ff1f2a563fa0877a9b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.1-py2.5-win32.egg
Algorithm Hash digest
SHA256 fe7d263e79fa4536d3f34bdaf202130842386051110e66404935014fa6b745e1
MD5 473e65d48c9001474a77f14cb6178e8b
BLAKE2b-256 9dd9c151283fe125f3bf37386f3e24740085f630b4a792685c5caafb83616873

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.1-py2.5-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 bcf8c968e29fed447045c88a4eb2c665f3fd56c5e82f4d53f3e91b8a09112a17
MD5 68d1d1a83e41f27269c4484c87b19031
BLAKE2b-256 4df0eb673ba9a21f8e0542c0f330edac5f8b3a192c13f550d38a9602ee2dfa04

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.1-py2.4-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 b28320f857375d18133126021d53baa685396d17611928667c20b7c4a28199f1
MD5 7fa8f8760954b5c959c1bc2967d3f48a
BLAKE2b-256 e3a87a73f3c992a2d50bd5ad06283b2eb9e3f1733427397f056002959997dcc8

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