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.1.2.tar.gz (94.8 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.1.2-py2.6-win32.egg (139.5 kB view details)

Uploaded Egg

pymongo-1.1.2-py2.6-macosx-10.6-i386.egg (139.3 kB view details)

Uploaded Egg

pymongo-1.1.2-py2.5-win32.egg (139.0 kB view details)

Uploaded Egg

pymongo-1.1.2-py2.5-macosx-10.6-i386.egg (139.6 kB view details)

Uploaded Egg

pymongo-1.1.2-py2.4-macosx-10.6-i386.egg (141.0 kB view details)

Uploaded Egg

File details

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

File metadata

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

File hashes

Hashes for pymongo-1.1.2.tar.gz
Algorithm Hash digest
SHA256 ffdb1cd84e91dc99ddb782b793138d084fc41eb2b1539844a58198ba17c6b660
MD5 627ff87b0cd14cd45e0bc5357426d180
BLAKE2b-256 17ba7584afe75f3037c23bd053139bc594d77de62ce4fe08be61a0cd906e2007

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.1.2-py2.6-win32.egg
Algorithm Hash digest
SHA256 aeaa4df812b4f3d676d6e4ed1fa4c55a7314467ca0861e8e3be3bfb48623ffa2
MD5 8f9591f62da5e8979e23ff0630161cd5
BLAKE2b-256 10b9309c8dbb38c643f8260fb96c455fa18f7e595b3eae8fad3a85d9fa1d8e43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.1.2-py2.6-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 982b8e6d3bcf748173484f92f5bd2bbfa1da5b5ebdd96379455fc34611257b59
MD5 b756c42c93b130a2a2cdaf06121c99ac
BLAKE2b-256 989bc48013443f55c67f7abbc3416534eab197edeb311bbe08560bac95549869

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.1.2-py2.5-win32.egg
Algorithm Hash digest
SHA256 e0160c7fd87ee0ab2a7d77d23b9938382742e62fc23d1d3207bbff53bb5c9f7b
MD5 0c9002f9fa835501126351028561434f
BLAKE2b-256 70891987441a1bd1361f218c655d668374788218f7a8bbb059351224d036a278

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.1.2-py2.5-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 6ec348f4f34f71d830acec516e73f8363e8deb2147aa04d614f2affcc8dddd4a
MD5 a9413ecf8b06ce7210363b477231b061
BLAKE2b-256 a307e89d043933c14c5eab3ee9af38570d60858076f8655bc93c23b9507c1b45

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymongo-1.1.2-py2.4-macosx-10.6-i386.egg
Algorithm Hash digest
SHA256 6470bd7801b1e7b7c4e05edd32e42577168af471a52e4be97191290e01fa52e4
MD5 22daa05173cc59eab37a94a8674b9924
BLAKE2b-256 ccb2e03e3f29382305f8f242103e76ffa4b960a22affe5df12caacab96f0ac81

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