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

  • 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

Project details


Release history Release notifications | RSS feed

This version

1.0

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

Uploaded Source

Built Distributions

pymongo-1.0-py2.6-win32.egg (129.4 kB view details)

Uploaded Source

pymongo-1.0-py2.6-macosx-10.6-i386.egg (129.0 kB view details)

Uploaded Source

pymongo-1.0-py2.5-win32.egg (128.7 kB view details)

Uploaded Source

pymongo-1.0-py2.5-macosx-10.6-i386.egg (129.2 kB view details)

Uploaded Source

pymongo-1.0-py2.4-macosx-10.6-i386.egg (130.5 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for pymongo-1.0.tar.gz
Algorithm Hash digest
SHA256 2df84f1fe9e446ea16881d58f7fbc521981ef12634f9ee673f34b455c122d1ce
MD5 5c5112e407b2614b73acb4e4a022b7bd
BLAKE2b-256 aeddde6923f4a3c9ed26ad7538e08fec3ccbd01f830ea26f56dc5b469710b713

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.0-py2.6-win32.egg
Algorithm Hash digest
SHA256 8c2ccdb08d66341ebf09a3bba484bc1aa25b800d384fbaddc778026bb1be7a9b
MD5 7b7683f1c58f0b9947a9b64c3e523c33
BLAKE2b-256 5a830e5e980a8e2b345d8e9e615da1b22197ccc1db257d8eef4dc25f71b80bfe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.0-py2.6-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 b5b9c27690f40677a79ec7ecd336290a4ba962f0093a185a3697374859a9e785
MD5 4dcbc16076acbf4a29d1d524fc06442b
BLAKE2b-256 69f50f52412a42183dfd90da7bc276fdfbe2c4b7a9d29bd9725c0ed134a916db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.0-py2.5-win32.egg
Algorithm Hash digest
SHA256 911c343274f7390a60dba958f01dbe38685be6f288e8b7a4b01f0c61efa9b5fd
MD5 40245845461f341fb633f07e06dc062f
BLAKE2b-256 309de955b9c693f65e792a74410b0f0d3075cba2ba4d9d52ad224b94924bec95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.0-py2.5-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 ca35120462759f42e7c11e9695bd46859604097240bc0af0f03c1f0566db5f49
MD5 3ab2025e898c7b0a7d17d16b7dd1cf96
BLAKE2b-256 e8eb650c86dfae5431ea32616f7ee895cbccbb31d9ff2091a5fb45c02424f6c3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.0-py2.4-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 fa83e913f6b65afbf898ad1da6addc070f56453241fba9f004273ea7448db038
MD5 4cfc36617cfe3080a73fa6121caca912
BLAKE2b-256 00f805a50125c71705ffee26cbbe2bd61c2582516b85a9d0817a72ce5221ff08

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