This seems to be a very popular blog post on this blog. Here it is again for those who want to play around with Python and MongoDB.
The code below demonstrates how to use Python to connect to a MongoDB database. I chose to use a cloud based instance of MongoDB provided free of charge by MongoLab.com. The script demonstrates how to:
- Use the PyMongo library to connect to a Mongo database
- Insert documents into a collection
- Display all of the documents from the collection
I also used a local instance of MongoDB for testing. You will will need to use a Python package manager such as EasyInstall to install the PyMongo library.
Here is the Python code:
If you have any questions please let me know.