for any info/changes follow me: @nickmilon

mongoUtils.client module

MongoDB client

class mongoUtils.client.muClient(*args, **kwargs)[source]

Bases: pymongo.mongo_client.MongoClient

An enhanced mongoDB client with some extra features use it within a with statement or else call close() when instance is not needed any more see mongo_client

Property:db instances are initialized with a default property self.db pointing to the database if one is included in connection string otherwise it’s value is None appls can set it by calling the use() method
..Warning:: for efficiency this class descents from MongoClient and shares the way it uses
class name space. So be very careful when defining methods names in descendant classes to avoid masking potential database names to be addressed by pymongo’s dot notation so client.nodes can’t refer to a database coz it is the name of a method in pymongo if you have to refer to nodes as database use the client[nodes] form
Parameters:see here
__init__(*args, **kwargs)[source]
cl_colstats(details=2, verbose=True)[source]
cl_schema(details=1, verbose=True)[source]

mimics use console command

cl_db_set(name, codec_options=None, read_preference=None, write_concern=None)[source]

returns a database with specified options


override in subclasses to initialize things i.e:

>>> self.users=self.db['users']
>>> self.users.ensure_index ("foo")