pymongo
– Python driver for MongoDB¶
Python driver for MongoDB.
-
pymongo.
version
= '2.7.2'¶ Current version of PyMongo.
-
pymongo.
MongoClient
¶ Alias for
pymongo.mongo_client.MongoClient
.
-
pymongo.
MongoReplicaSetClient
¶ Alias for
pymongo.mongo_replica_set_client.MongoReplicaSetClient
.
-
class
pymongo.read_preferences.
ReadPreference
¶ An enum that defines the read preference modes supported by PyMongo. Used in three cases:
MongoClient
connected to a single host:- PRIMARY: Queries are allowed if the host is standalone or the replica set primary.
- All other modes allow queries to standalone servers, to the primary, or to secondaries.
MongoClient
connected to a mongos, with a sharded cluster of replica sets:- PRIMARY: Queries are sent to the primary of a shard.
- PRIMARY_PREFERRED: Queries are sent to the primary if available, otherwise a secondary.
- SECONDARY: Queries are distributed among shard secondaries. An error is raised if no secondaries are available.
- SECONDARY_PREFERRED: Queries are distributed among shard secondaries, or the primary if no secondary is available.
- NEAREST: Queries are distributed among all members of a shard.
- PRIMARY: Queries are sent to the primary of the replica set.
- PRIMARY_PREFERRED: Queries are sent to the primary if available, otherwise a secondary.
- SECONDARY: Queries are distributed among secondaries. An error is raised if no secondaries are available.
- SECONDARY_PREFERRED: Queries are distributed among secondaries, or the primary if no secondary is available.
- NEAREST: Queries are distributed among all members.
-
pymongo.
has_c
()¶ Is the C extension installed?
New in version 1.5.
-
pymongo.
MIN_SUPPORTED_WIRE_VERSION
¶ The minimum wire protocol version PyMongo supports.
-
pymongo.
MAX_SUPPORTED_WIRE_VERSION
¶ The maximum wire protocol version PyMongo supports.
Sub-modules:
connection
– Tools for connecting to MongoDBdatabase
– Database level operationscollection
– Collection level operationscommand_cursor
– Tools for iterating over MongoDB command resultscursor
– Tools for iterating over MongoDB query resultsbulk
– The bulk write operations interfaceerrors
– Exceptions raised by thepymongo
packagemaster_slave_connection
– Master-slave connection to MongoDBmessage
– Tools for creating messages to be sent to MongoDBmongo_client
– Tools for connecting to MongoDBmongo_replica_set_client
– Tools for connecting to a MongoDB replica setpool
– Pool module for use with a MongoDB client.replica_set_connection
– Tools for connecting to a MongoDB replica setson_manipulator
– Manipulators that can edit SON documents as they are saved or retrievedcursor_manager
– Managers to handle when cursors are killed after being closed – DEPRECATEDuri_parser
– Tools to parse and validate a MongoDB URI