The PyMongo distribution contains three top-level packages for interacting with MongoDB. apt-get install pymongo mongo_client – Tools for connecting to MongoDB from pymongo import MongoClient class pymongo.mongo_client.MongoClient([host='localhost'[, port=27017[, max_pool_size=100[, document_class=dict[, tz_aware=False[, **kwargs]]]]]]) disconnect() close() alive() host port is_primary is_mongos database_names() drop_database(name_or_database) copy_database(from_name, to_name[, from_host=None[, username=None[, password=None]]]) get_default_database() server_info() c[db_name] || c.db_name Get the db_name Database on MongoClient c. Raises InvalidName if an invalid database name is used. database – Database level operations safe add_user(name, password=None, read_only=None, **kwargs) authenticate(name, password=None, source=None, mechanism='DEFAULT', **kwargs) collection_names(include_system_collections=True) command(command, value=1, check=True, allowable_errors=, []uuid_subtype=3, compile_re=True, **kwargs) connection create_collection(name, **kwargs) drop_collection(name_or_collection) logout() name db[collection_name] || db.collection_name Get the collection_name Collection of Database db. Raises InvalidName if an invalid collection name is used. collection – Collection level operations c[name] || c.name Get the name sub-collection of Collection c. Raises InvalidName if an invalid collection name is used. full_name name database insert(doc_or_docs[, manipulate=True[, safe=None[, check_keys=True[, continue_on_error=False[, **kwargs]]]]]) save(to_save[, manipulate=True[, safe=None[, check_keys=True[, **kwargs]]]]) update(spec, document[, upsert=False[, manipulate=False[, safe=None[, multi=False[, check_keys=True[, **kwargs]]]]]]) remove([spec_or_id=None[, safe=None[, multi=True[, **kwargs]]]]) drop() find([spec=None[, fields=None[, skip=0[, limit=0[, timeout=True[, snapshot=False[, tailable=False[, sort=None[, max_scan=None[, as_class=None[, slave_okay=False[, await_data=False[, partial=False[, manipulate=True[, read_preference=ReadPreference.PRIMARY[, exhaust=False[, compile_re=True[, **kwargs]]]]]]]]]]]]]]]]]]) find_one([spec_or_id=None[, *args[, **kwargs]]]) count() create_index(key_or_list, cache_for=300, **kwargs) drop_index(index_or_name) drop_indexes() reindex() index_information() group(key, condition, initial, reduce, finalize=None, **kwargs) rename(new_name, **kwargs) distinct(key) map_reduce(map, reduce, out, full_response=False, **kwargs) find_and_modify(query={}, update=None, upsert=False, sort=None, full_response=False, manipulate=False, **kwargs) cursor – Tools for iterating over MongoDB query results c[index] add_option(mask) alive batch_size(batch_size) clone() close() collection comment(comment) conn_id count(with_limit_and_skip=False) cursor_id distinct(key) limit(limit) sort(key_or_list, direction=None)