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

This version

0.16

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

Uploaded Source

Built Distributions

pymongo-0.16-py2.6-win32.egg (126.0 kB view details)

Uploaded Source

pymongo-0.16-py2.6-macosx-10.6-i386.egg (125.7 kB view details)

Uploaded Source

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

Uploaded Source

pymongo-0.16-py2.5-macosx-10.6-i386.egg (125.7 kB view details)

Uploaded Source

pymongo-0.16-py2.4-macosx-10.6-i386.egg (127.2 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for pymongo-0.16.tar.gz
Algorithm Hash digest
SHA256 ee58a04a2523a8b159fbaff518c72e623a033f16b3e06bfa8e505885fac9fb75
MD5 d51878f52b14f20acb384bb01c196551
BLAKE2b-256 651233b0c5fd9bc515b6d653803fa860e32f168b49c5f5b0a496ea9a5356d6e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.16-py2.6-win32.egg
Algorithm Hash digest
SHA256 f4f223edc19e0e64df452e51f5122134d2ceff7aac1b9aeb93b683df51e2481d
MD5 d1b2641b064e786350eea0d4c9de6f38
BLAKE2b-256 38a7fd004690484031abe7307a7e270f42e01a2b33f0a15600e3712a0047a038

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.16-py2.6-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 c9dfc1fd4e6d6a302233d6aff3091e0ecefdf4b6d05d8b6bb78c42c569a46d31
MD5 44b11b7a8ca00d30e14da3e54fe70671
BLAKE2b-256 b25f831a6f2826fb2d9c9033dce47fe5c3767651e2652e33149093ed03da4daf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.16-py2.5-win32.egg
Algorithm Hash digest
SHA256 9cf8919c8e8c6ae5c25a79ae134a2dd8d3b2dbde69245d71a218f18f85e09c06
MD5 f2026d0b4e4235e5d7af9d8bb7284e5d
BLAKE2b-256 10edbe26504ad5c4b8361e3a000fe2f459e2f795b74a08cfea98f38125c8fc94

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.16-py2.5-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 1cc85ce9a6899c111a57d49af1de8cfb099131658219b8b5b328d0d394697c32
MD5 f5f986ae270e4a525a77fd16fdb6ad0b
BLAKE2b-256 07f3c8ae59519a9f44c3021877c439eaa96d2e23377635db6c3549e71c43335c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-0.16-py2.4-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 719633ea85948fbe54bc56669625f202c9c8a917647af94a1074bafce19ba442
MD5 1f409da846dfccb3f88e5678b30932be
BLAKE2b-256 31824d5fe461d7522174241d7213d4ee1f25c99d5269300104eca64ca31537d9

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 Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page