Python driver for MongoDB <http://www.mongodb.org>
Project description
- Info:
See the mongo site for more information. See github for the latest source.
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
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
Built Distributions
Hashes for pymongo-0.15-py2.6-macosx-10.5-i386.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77e46825be8ff54064e93eeb2196ef06c843754b1e966b32ed3e3db955dfed7c |
|
MD5 | 99d613dbe9ebda2ed53d003c7db4e325 |
|
BLAKE2b-256 | 9c34a0eb328fc4032d4098f161a6c499264898e1a1afde7143914d4f0f83652b |
Hashes for pymongo-0.15-py2.5-macosx-10.5-i386.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d285b9e90d2576cc85f6bf3d45d2f02ffb5b90cc8f3561cf2216e803f18efcf |
|
MD5 | 22110ffbd970c2fbd5aa643b459e231c |
|
BLAKE2b-256 | 2dd7c7f17c16626cbf52ae111a0b3d26783e2c55a3c2761eaa563d9e73dc217a |
Hashes for pymongo-0.15-py2.4-macosx-10.5-i386.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ee43f7d4cdb1b840d9586dc8e955064a26a7e18508f526d67b42d344b9dd91b |
|
MD5 | d982a3a3408189dac1f4bf3564422040 |
|
BLAKE2b-256 | a8ad826648c479176dfb7f53e57b924e148cb015dcb47a568be07eb32e373604 |
Hashes for pymongo-0.15-py2.3-macosx-10.5-i386.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00229caf34696be32f5f3ae419489c72e17019a52fd2ce69cb2225233fcb5249 |
|
MD5 | 85d27326985481fd8f3e4870ebe44921 |
|
BLAKE2b-256 | f5f0f7ba3d4272e8f5df5f65d1ce96caae85d13af4b20f598cc97910fd36c9d7 |