PyMongo
- 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
Metadata
Release files for pymongo 0.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pymongo-0.15.tar.gz | 83.9 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pymongo-0.15-py2.6-win32.egg | Legacy Egg format | - | - | Details |
| pymongo-0.15-py2.6-macosx-10.5-i386.egg | Legacy Egg format | - | - | Details |
| pymongo-0.15-py2.5-win32.egg | Legacy Egg format | - | - | Details |
| pymongo-0.15-py2.5-macosx-10.5-i386.egg | Legacy Egg format | - | - | Details |
| pymongo-0.15-py2.4-macosx-10.5-i386.egg | Legacy Egg format | - | - | Details |
| pymongo-0.15-py2.3-macosx-10.5-i386.egg | Legacy Egg format | - | - | Details |
Total release size: 1.1 MB
Release files / pymongo-0.15.tar.gz
| Download URL | pymongo-0.15.tar.gz |
|---|---|
| Size | 83.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
82ed26a03762797a14e33e33896fa7003a96aaca677d902509a53adeea41c787
|
|
BLAKE2b-256 checksum How to use checksums |
e1e1a741476b242af27f985021127d5de610cc8ac852426dd1a8d4076bc1d45c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pymongo-0.15-py2.6-win32.egg
| Download URL | pymongo-0.15-py2.6-win32.egg |
|---|---|
| Size | 125.5 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
ee2be3920cc1b0c8d93090b04810f8a4e94514d74bc929775a52faa796a766b5
|
|
BLAKE2b-256 checksum How to use checksums |
6638c8793024ea7a34e33716d19f71e138ee0f369c7449e0cf13f67ff0910820
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pymongo-0.15-py2.6-macosx-10.5-i386.egg
| Download URL | pymongo-0.15-py2.6-macosx-10.5-i386.egg |
|---|---|
| Size | 124.7 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
77e46825be8ff54064e93eeb2196ef06c843754b1e966b32ed3e3db955dfed7c
|
|
BLAKE2b-256 checksum How to use checksums |
9c34a0eb328fc4032d4098f161a6c499264898e1a1afde7143914d4f0f83652b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pymongo-0.15-py2.5-win32.egg
| Download URL | pymongo-0.15-py2.5-win32.egg |
|---|---|
| Size | 125.4 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
6accb7a6ebb084342c1e7c939f2f70844d1045638cd29eee850819c8bb19d5fb
|
|
BLAKE2b-256 checksum How to use checksums |
34328f271d00f033162aaea460ba05abe382cf09f56e84033b37c0012a17ae2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pymongo-0.15-py2.5-macosx-10.5-i386.egg
| Download URL | pymongo-0.15-py2.5-macosx-10.5-i386.egg |
|---|---|
| Size | 124.9 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
5d285b9e90d2576cc85f6bf3d45d2f02ffb5b90cc8f3561cf2216e803f18efcf
|
|
BLAKE2b-256 checksum How to use checksums |
2dd7c7f17c16626cbf52ae111a0b3d26783e2c55a3c2761eaa563d9e73dc217a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pymongo-0.15-py2.4-macosx-10.5-i386.egg
| Download URL | pymongo-0.15-py2.4-macosx-10.5-i386.egg |
|---|---|
| Size | 126.2 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
3ee43f7d4cdb1b840d9586dc8e955064a26a7e18508f526d67b42d344b9dd91b
|
|
BLAKE2b-256 checksum How to use checksums |
a8ad826648c479176dfb7f53e57b924e148cb015dcb47a568be07eb32e373604
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pymongo-0.15-py2.3-macosx-10.5-i386.egg
| Download URL | pymongo-0.15-py2.3-macosx-10.5-i386.egg |
|---|---|
| Size | 379.4 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
00229caf34696be32f5f3ae419489c72e17019a52fd2ce69cb2225233fcb5249
|
|
BLAKE2b-256 checksum How to use checksums |
f5f0f7ba3d4272e8f5df5f65d1ce96caae85d13af4b20f598cc97910fd36c9d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |