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

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

Uploaded Source

Built Distributions

pymongo-0.14.2-py2.6-win32.egg (124.7 kB view details)

Uploaded Source

pymongo-0.14.2-py2.6-macosx-10.5-i386.egg (123.8 kB view details)

Uploaded Source

pymongo-0.14.2-py2.5-macosx-10.5-i386.egg (123.9 kB view details)

Uploaded Source

pymongo-0.14.2-py2.4-macosx-10.5-i386.egg (125.3 kB view details)

Uploaded Source

pymongo-0.14.2-py2.3-macosx-10.5-i386.egg (375.8 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for pymongo-0.14.2.tar.gz
Algorithm Hash digest
SHA256 66b4b24f5898ab3ecd97f711d830f68df5d3cdf8a46fd899d706ab83f4571493
MD5 e4b20bb2935f0d000dfda0f9c99c75cc
BLAKE2b-256 645b98c1219d65b59124e74621d50ffd057484b58d54e6822b462a51a4c5eb44

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.14.2-py2.6-win32.egg
Algorithm Hash digest
SHA256 8775b45a2a5e64d6a36a318362cc11850df481ea451c19ee3181b582e2acdc8f
MD5 7495c96aaa26971e18b334d4cef2027d
BLAKE2b-256 6e39443ef205248031fa165b79a5dc14554ef35fecde0c9a3f415777d1611e6b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.14.2-py2.6-macosx-10.5-i386.egg
Algorithm Hash digest
SHA256 793b98ddba27064985a673158b69d3e83cdade87edbf4445826a3828916ff0cc
MD5 9c53e0f4d0c0b9ae8f76fddb048a9e5f
BLAKE2b-256 014aa2bf9d31133b99b9667361cc3d8671a36c2077ced0c328297ded48a73d4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.14.2-py2.5-macosx-10.5-i386.egg
Algorithm Hash digest
SHA256 d4bb3bed1083ec1952aa52fc64b171a2f4c421dff41bb9ea9f7fab84f48bb0e5
MD5 1f483c5676c3dd34aff36996d1f87cfd
BLAKE2b-256 4330b24d4569b9a754ed4d126d603b744bc08a89d50da217b1f0e7ce355e6add

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.14.2-py2.4-macosx-10.5-i386.egg
Algorithm Hash digest
SHA256 726f4375b40be36beadb2b470c98d7d831d2b7314465e54470e8c815c9e11d7e
MD5 545c72703c4f42421dce67ad3df03000
BLAKE2b-256 59f0ed5448b834f16d8bdd6d69e9f0576fa25cbfcf465514876569919bdbc7a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.14.2-py2.3-macosx-10.5-i386.egg
Algorithm Hash digest
SHA256 47f2ab7d3e13c78b55697ee3871cb6db32b6d66c950327f92887b879cb0a9fb9
MD5 81848ae64fc1368dde98bc2b7fd6f1bc
BLAKE2b-256 4306382245be97116c049571ef875f9ba2fe2086fb4a1ae22173dd2cab050da6

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