First, set up a virtualenv.

Make sure that your mongo server is running.

In the virtualenv, install pymongo, then try out this .py file in the virtualenv.

from pymongo import MongoClient
client = MongoClient()
db = client['test-database']
collection = db['test-collection']
print(collection.insert_one({'my_key': 'some value'}))

The printout shows the ID assigned by mongodb to the data you stored. You can now try to look it up.

You can also follow tutorial.

Created by Leon Poon on 2018/12/24 09:47

Need help?

If you need help with XWiki you can contact: