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) sphinx

  • (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 sphinx installed to generate the documentation. Documentation can be generated by running python setup.py doc. Generated documentation can be found in the doc/build/html/ 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.

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

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pymongo-1.2.1-py2.6-win32.egg (145.3 kB view details)

Uploaded Egg

pymongo-1.2.1-py2.6-macosx-10.6-i386.egg (145.3 kB view details)

Uploaded Egg

pymongo-1.2.1-py2.5-win32.egg (144.9 kB view details)

Uploaded Egg

pymongo-1.2.1-py2.5-macosx-10.6-i386.egg (145.6 kB view details)

Uploaded Egg

pymongo-1.2.1-py2.4-macosx-10.6-i386.egg (146.8 kB view details)

Uploaded Egg

File details

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

File metadata

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

File hashes

Hashes for pymongo-1.2.1.tar.gz
Algorithm Hash digest
SHA256 f639e6c177d26eac8abb956249de591632ac049c71838e3a7e0f8492db2896a8
MD5 bd9aa7273468304055875baaa582ddd3
BLAKE2b-256 d7297679dc4fb2d193daebd884806285efb87da88eee205bdb2bd24345a5bc56

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.2.1-py2.6-win32.egg
Algorithm Hash digest
SHA256 717e4b5bba3e09b8fce837ab15a21a9baed27c7bca6df7d17ca2deadaeaa9d01
MD5 db346576f011787001e9f586c047fc5c
BLAKE2b-256 786bfeed2eb8500c758238b74e6db3ec78df147ff6624b5ec6ea5b526b16cff3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.2.1-py2.6-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 b60f5f88f849bac90a653ed5a8d1390e5d8629c3806ef010d46a7f8121bd1cf3
MD5 0e4c9aec5021ace00ba7e620e6718b77
BLAKE2b-256 ba508f73acc32e213e675660e0aa4c5e035a8d888e995a3af4b26cf6d1ee9349

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.2.1-py2.5-win32.egg
Algorithm Hash digest
SHA256 33bd5d2564e21c72b923eb6a90c6090971355fcdd37b2124c984682e9e00836f
MD5 e7274f4494a3875f8eedbfc23b5db5d7
BLAKE2b-256 ca37b7df4e993c765e75923893679b3df733eabc62a809842194441d58481780

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.2.1-py2.5-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 bac403c2655fb06052d4e418605bc3043b6849752504bef1c10c6198c33fdec2
MD5 140e33b42a9ca835fe019f0f1f9089a5
BLAKE2b-256 a751fe84c8133197dd989324a5fb15927a6849131d915626e698e85045b2b8f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.2.1-py2.4-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 0d1df5b55582dc5b03820df131f48a2dc69036f270dc9b632357f6d13d756709
MD5 c652de0ae35da7bbb0a74f9b09792d87
BLAKE2b-256 10d7a7e08dd0af3b727f39614830e37d2c0302615b61ad18e2d7d725f7af56d7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page