pymongo – Python driver for MongoDB

Python driver for MongoDB.

pymongo.version = '2.2rc1'

Current version of PyMongo.

pymongo.Connection

Alias for pymongo.connection.Connection.

pymongo.ReplicaSetConnection

Alias for pymongo.replica_set_connection.ReplicaSetConnection.

class pymongo.ReadPreference

An enum that defines the read preferences supported by PyMongo.

Connection type Read Preference
  PRIMARY SECONDARY SECONDARY_ONLY
Connection to a single host. Queries are allowed if the connection is to the replica set primary. Queries are allowed if the connection is to the replica set primary or a secondary. Same as SECONDARY
Connection to a mongos. Queries are sent to the primary of a shard. Queries are distributed among shard secondaries. Queries are sent to the primary if no secondaries are available. Same as SECONDARY
ReplicaSetConnection Queries are sent to the primary of the replica set. Queries are distributed among replica set secondaries. Queries are sent to the primary if no secondaries are available. Queries are never sent to the replica set primary. An exception is raised if no secondary is available.
pymongo.has_c()

Is the C extension installed?

New in version 1.5.

Sub-modules:

Previous topic

tz_util – Utilities for dealing with timezones in Python

Next topic

connection – Tools for connecting to MongoDB

This Page