To get started with Ming just install it with:

Connecting to MongoDB¶

Before we start, make sure you have a copy of MongoDB running. First thing needed to start using Ming is to tell it how to connect to our instance of mongod. For this we use the create_datastore() function, this function creates a connection to the MongoDB instance, replicaset or cluster specified by the given URL:

from ming import create_datastore from ming.odm import ThreadLocalODMSession session = ThreadLocalODMSession ( bind = create_datastore ( 'odm_welcome' ) )

The ThreadLocalODMSession is the object all your models will use to interact with MongoDB and can be directly used to perform low-level mongodb oprations. While this provides no particular benefit over using pymongo directly it already permits to create and query documents: