skip to navigation
skip to content

Not Logged In

pymongo3 1.9b1

Python driver for MongoDB <http://www.mongodb.org>

Latest Version: Unknown

About

DEPRECATED - DO NOT USE -- The official pymongo driver has reached Python 3.x compatibility in version 2.2, so do not use this port any more.

This is a semi-official port of PyMongo 1.9+ to Python 3.x. Semantics are mostly compatible with the official PyMongo branch, except for a few things listed in the next section. This port can currently only be used on Python 3.1 or later. Compatibility with Python 2.6+ may be added in the future.

The PyMongo distribution contains tools for interacting with MongoDB database from Python. The bson package is an implementation of the BSON format for Python. The pymongo package is a native Python driver for MongoDB. The gridfs package is a gridfs implementation on top of pymongo.

About the Py3K port

Byte strings and unicode strings were clearly separated in Python 3. PyMongo3 adapts to these changes by decoding Binary of subtype 0 to the "bytes" type. There has been considerable effort to make things work the way developers would expect them to, with regards to the new semantics of Python 3. If you feel that the new semantics don't match your expectations, feel free to ask on the mailing list or create a new issue on github (see the next section for that).

Issues / Questions / Feedback

Any issues with, questions about, or feedback for PyMongo3 should be sent to the mongodb-user list on Google Groups. For confirmed issues or feature requests, open a case on github. Please do not e-mail any of the PyMongo developers directly with issues or questions - you're more likely to get an answer on the list.

Installation

If you have distribute installed you should be able to do easy_install pymongo3 to install PyMongo. Otherwise you can download the project source and do python setup.py install to install.

Dependencies

The PyMongo3 distribution is supported and tested on Python 3.x, where x >= 1.

Additional dependencies are:

  • (to generate documentation) sphinx
  • (to auto-discover tests) nose

Examples

Here's a basic example (for more see the examples section of the docs):

>>> import pymongo
>>> connection = pymongo.Connection("localhost", 27017)
>>> db = connection.test
>>> db.name()
'test'
>>> db.my_collection
Collection(Database(Connection('localhost', 27017), 'test'), '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()
{'x': 10, '_id': ObjectId('4aba15ebe23f6b53b0000000')}
>>> for item in db.my_collection.find():
...     print item["x"]
...
10
8
11
>>> db.my_collection.create_index("x")
'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 the Python 3.x compatible fork of nosetests, nose3 and run nosetests3 or python setup.py test in the root of the distribution. Tests are located in the test/ directory.

 
File Type Py Version Uploaded on Size
pymongo3-1.9b1.tar.gz (md5) Source 2010-12-11 148KB
pymongo3-1.9b1.win-amd64-py3.1.exe (md5) MS Windows installer 3.1 2010-12-16 333KB
pymongo3-1.9b1.win-amd64-py3.2.exe (md5) MS Windows installer 3.2 2011-03-13 333KB
pymongo3-1.9b1.win32-py3.1.exe (md5) MS Windows installer 3.1 2010-12-16 303KB
pymongo3-1.9b1.win32-py3.2.exe (md5) MS Windows installer 3.2 2011-03-13 303KB
  • Downloads (All Versions):
  • 5 downloads in the last day
  • 101 downloads in the last week
  • 498 downloads in the last month