mongo-python-driver の API リファレンス
mongo-python-driver (mongodb/mongo-python-driver) の公開 API 400 件 —— クラス 112、関数 56、メソッド 232。実際のソースを静的解析して抽出した正確なシグネチャを掲載しています。
リポジトリ: mongodb/mongo-python-driver
| 種別 | 件数 |
|---|---|
| クラス | 112 |
| 関数 | 56 |
| メソッド | 232 |
API 一覧
class
_setup.custom_build_extAllow C extension building to fail.
class
bson.BSONBSON (Binary JSON) data.
method
bson.BSON.decode(codec_options:CodecOptions[Any]=DEFAULT_CODEC_OPTIONS) -> dict[str, Any]Decode this BSON data.
method
bson.BSON.encode(document:Mapping[str, Any], check_keys:bool=False, codec_options:CodecOptions[Any]=DEFAULT_CODEC_OPTIONS) -> BSONEncode a document to a new :class:`BSON` instance.
class
bson.binary.BinaryRepresentation of BSON binary data.
method
bson.binary.Binary.as_uuid(uuid_representation:int=UuidRepresentation.STANDARD) -> UUIDCreate a Python UUID from this BSON Binary object.
method
bson.binary.Binary.from_uuid(uuid:UUID, uuid_representation:int=UuidRepresentation.STANDARD) -> BinaryCreate a BSON Binary object from a Python UUID.
method
bson.binary.Binary.subtype() -> intSubtype of this binary data.
class
bson.binary.BinaryVectorDtypeDatatypes of vector subtype.
class
bson.code.CodeBSON's JavaScript code type.
method
bson.code.Code.scope() -> Optional[Mapping[str, Any]]Scope dictionary for this instance or ``None``.
class
bson.codec_options.DatetimeConversionOptions for decoding BSON datetimes.
method
bson.codec_options.TypeRegistry.codecs() -> list[TypeEncoder | TypeDecoder | TypeCodec]The list of type codecs in this registry.
method
bson.codec_options.TypeRegistry.fallback_encoder() -> Optional[_Fallback]The fallback encoder in this registry.
class
bson.datetime_ms.DatetimeMSRepresents a BSON UTC datetime.
class
bson.dbref.DBRefA reference to a document stored in MongoDB.
method
bson.dbref.DBRef.as_doc() -> SON[str, Any]Get the SON document representation of this DBRef.
method
bson.dbref.DBRef.collection() -> strGet the name of this DBRef's collection.
method
bson.dbref.DBRef.database() -> Optional[str]Get the name of this DBRef's database.
method
bson.dbref.DBRef.id() -> AnyGet this DBRef's _id.
func
bson.encode(document:Mapping[str, Any], check_keys:bool=False, codec_options:CodecOptions[Any]=DEFAULT_CODEC_OPTIONS) -> bytesEncode a document to BSON.
class
bson.errors.BSONErrorBase class for all BSON exceptions.
class
bson.errors.InvalidIdRaised when trying to create an ObjectId from invalid data.
func
bson.has_c() -> boolIs the C extension installed?
class
bson.int64.Int64Representation of the BSON int64 type.
func
bson.is_valid(bson:bytes) -> boolCheck that the given string represents valid :class:`BSON` data.
func
bson.json_util.dumps(obj:Any, *args:Any, **kwargs:Any) -> strHelper function that wraps :func:`json.dumps`.
func
bson.json_util.get_size(obj:Any, max_size:int, current_size:int=0) -> intRecursively finds size of objects
func
bson.json_util.loads(s:Union[str, bytes, bytearray], *args:Any, **kwargs:Any) -> AnyHelper function that wraps :func:`json.loads`.
class
bson.max_key.MaxKeyMongoDB internal MaxKey type.
class
bson.min_key.MinKeyMongoDB internal MinKey type.
class
bson.objectid.ObjectIdA MongoDB ObjectId.
method
bson.objectid.ObjectId.binary() -> bytes12-byte binary representation of this ObjectId.
method
bson.objectid.ObjectId.is_valid(oid:Any) -> boolChecks if a `oid` string is valid or not.
class
bson.regex.RegexBSON regular expression data.
method
bson.regex.Regex.from_native(regex:Pattern[_T]) -> Regex[_T]Convert a Python regular expression into a ``Regex`` instance.
class
bson.son.SONSON data.
class
bson.timestamp.TimestampMongoDB internal timestamps used in the opLog.
method
bson.timestamp.Timestamp.inc() -> intGet the inc portion of this :class:`Timestamp`.
method
bson.timestamp.Timestamp.time() -> intGet the time portion of this :class:`Timestamp`.
class
bson.tz_util.FixedOffsetFixed offset timezone, in minutes east from UTC.
class
gridfs.asynchronous.grid_file.AsyncGridFSAn instance of GridFS on top of a single Database.
method
gridfs.asynchronous.grid_file.AsyncGridFS.delete(file_id:Any, session:Optional[AsyncClientSession]=None) -> NoneDelete a file from GridFS by ``"_id"``.
method
gridfs.asynchronous.grid_file.AsyncGridFS.find(*args:Any, **kwargs:Any) -> AsyncGridOutCursorQuery GridFS for files.
method
gridfs.asynchronous.grid_file.AsyncGridFS.find_one(filter:Optional[Any]=None, session:Optional[AsyncClientSession]=None, *args:Any, **kwargs:Any) -> Optional[AsyncGridOut]Get a single file from gridfs.
method
gridfs.asynchronous.grid_file.AsyncGridFS.get(file_id:Any, session:Optional[AsyncClientSession]=None) -> AsyncGridOutGet a file from GridFS by ``"_id"``.
method
gridfs.asynchronous.grid_file.AsyncGridFS.new_file(**kwargs:Any) -> AsyncGridInCreate a new file in GridFS.
method
gridfs.asynchronous.grid_file.AsyncGridFS.put(data:Any, **kwargs:Any) -> AnyPut data in GridFS as a new file.
class
gridfs.asynchronous.grid_file.AsyncGridFSBucketAn instance of GridFS on top of a single Database.
class
gridfs.asynchronous.grid_file.AsyncGridInClass to write data to GridFS.
method
gridfs.asynchronous.grid_file.AsyncGridIn.close() -> NoneFlush the file and close it.
method
gridfs.asynchronous.grid_file.AsyncGridIn.closed() -> boolIs this file closed?
method
gridfs.asynchronous.grid_file.AsyncGridIn.write(data:Any) -> NoneWrite data to the file.
method
gridfs.asynchronous.grid_file.AsyncGridIn.writelines(sequence:Iterable[Any]) -> NoneWrite a sequence of strings to the file.
class
gridfs.asynchronous.grid_file.AsyncGridOutClass to read data out of GridFS.
method
gridfs.asynchronous.grid_file.AsyncGridOut.close() -> NoneMake GridOut more generically file-like.
method
gridfs.asynchronous.grid_file.AsyncGridOut.readchunk() -> bytesReads a chunk at a time.
method
gridfs.asynchronous.grid_file.AsyncGridOut.readline(size:int=-1) -> bytesRead one line or up to `size` bytes from the file.
method
gridfs.asynchronous.grid_file.AsyncGridOut.readlines(size:int=-1) -> list[bytes]Read one line or up to `size` bytes from the file.
method
gridfs.asynchronous.grid_file.AsyncGridOut.seek(pos:int, whence:int=_SEEK_SET) -> intSet the current position of this file.
method
gridfs.asynchronous.grid_file.AsyncGridOut.tell() -> intReturn the current position of this file.
class
gridfs.errors.CorruptGridFileRaised when a file in :class:`~gridfs.GridFS` is malformed.
class
gridfs.errors.FileExistsRaised when trying to create a file that already exists.
class
gridfs.errors.GridFSErrorBase class for all GridFS exceptions.
class
gridfs.errors.NoFileRaised when trying to read from a non-existent file.
class
gridfs.synchronous.grid_file.GridFSAn instance of GridFS on top of a single Database.
method
gridfs.synchronous.grid_file.GridFS.delete(file_id:Any, session:Optional[ClientSession]=None) -> NoneDelete a file from GridFS by ``"_id"``.
method
gridfs.synchronous.grid_file.GridFS.find(*args:Any, **kwargs:Any) -> GridOutCursorQuery GridFS for files.
method
gridfs.synchronous.grid_file.GridFS.find_one(filter:Optional[Any]=None, session:Optional[ClientSession]=None, *args:Any, **kwargs:Any) -> Optional[GridOut]Get a single file from gridfs.
method
gridfs.synchronous.grid_file.GridFS.get(file_id:Any, session:Optional[ClientSession]=None) -> GridOutGet a file from GridFS by ``"_id"``.
method
gridfs.synchronous.grid_file.GridFS.new_file(**kwargs:Any) -> GridInCreate a new file in GridFS.
method
gridfs.synchronous.grid_file.GridFS.put(data:Any, **kwargs:Any) -> AnyPut data in GridFS as a new file.
class
gridfs.synchronous.grid_file.GridFSBucketAn instance of GridFS on top of a single Database.
class
gridfs.synchronous.grid_file.GridInClass to write data to GridFS.
method
gridfs.synchronous.grid_file.GridIn.close() -> NoneFlush the file and close it.
method
gridfs.synchronous.grid_file.GridIn.closed() -> boolIs this file closed?
method
gridfs.synchronous.grid_file.GridIn.write(data:Any) -> NoneWrite data to the file.
method
gridfs.synchronous.grid_file.GridIn.writelines(sequence:Iterable[Any]) -> NoneWrite a sequence of strings to the file.
class
gridfs.synchronous.grid_file.GridOutClass to read data out of GridFS.
method
gridfs.synchronous.grid_file.GridOut.close() -> NoneMake GridOut more generically file-like.
method
gridfs.synchronous.grid_file.GridOut.readchunk() -> bytesReads a chunk at a time.
method
gridfs.synchronous.grid_file.GridOut.readline(size:int=-1) -> bytesRead one line or up to `size` bytes from the file.
method
gridfs.synchronous.grid_file.GridOut.readlines(size:int=-1) -> list[bytes]Read one line or up to `size` bytes from the file.
method
gridfs.synchronous.grid_file.GridOut.seek(pos:int, whence:int=_SEEK_SET) -> intSet the current position of this file.
method
gridfs.synchronous.grid_file.GridOut.tell() -> intReturn the current position of this file.
class
gridfs.synchronous.grid_file.GridOutChunkIteratorIterates over a file's chunks using a single cursor.
class
hatch_build.CustomHookThe pymongo build hook.
method
hatch_build.CustomHook.initialize(version, build_data)Initialize the hook.
class
pymongo._asyncio_lock.ConditionAsynchronous equivalent to threading.Condition.
method
pymongo._asyncio_lock.Condition.notify(n:int=1) -> NoneBy default, wake up one task waiting on this condition, if any.
method
pymongo._asyncio_lock.Condition.notify_all() -> NoneWake up all tasks waiting on this condition.
method
pymongo._asyncio_lock.Condition.wait() -> boolWait until notified.
method
pymongo._asyncio_lock.Condition.wait_for(predicate:Any) -> Coroutine[Any, Any, Any]Wait until a predicate becomes true.
class
pymongo._asyncio_lock.LockPrimitive lock objects.
method
pymongo._asyncio_lock.Lock.acquire() -> boolAcquire a lock.
method
pymongo._asyncio_lock.Lock.locked() -> boolReturn True if lock is acquired.
method
pymongo._asyncio_lock.Lock.release() -> NoneRelease a lock.
class
pymongo._csot.MovingMinimumTracks a minimum RTT within the last 10 RTT samples.
method
pymongo._csot.MovingMinimum.get() -> floatGet the min, or 0.0 if there aren't enough samples yet.
func
pymongo._csot.apply(func:F) -> FApply the client's timeoutMS to this operation.
func
pymongo._csot.apply_write_concern(cmd:MutableMapping[str, Any], write_concern:Optional[WriteConcern]) -> NoneApply the given write concern to a command.
func
pymongo._csot.clamp_remaining(max_timeout:float) -> floatReturn the remaining timeout clamped to a max value.
func
pymongo._telemetry.log_command_retry(topology_id:Optional[ObjectId], command_name:str, operation_id:Optional[int], attempt_number:int, is_write:bool) -> NoneEmit a command-retry log entry.
func
pymongo.asynchronous.auth.authenticate(credentials:MongoCredential, conn:AsyncConnection, reauthenticate:bool=False) -> NoneAuthenticate connection.
class
pymongo.asynchronous.client_session.AsyncClientSessionA session for ordering sequential operations.
method
pymongo.asynchronous.client_session.AsyncClientSession.abort_transaction() -> NoneAbort a multi-statement transaction.
method
pymongo.asynchronous.client_session.AsyncClientSession.advance_cluster_time(cluster_time:Mapping[str, Any]) -> NoneUpdate the cluster time for this session.
method
pymongo.asynchronous.client_session.AsyncClientSession.advance_operation_time(operation_time:Timestamp) -> NoneUpdate the operation time for this session.
method
pymongo.asynchronous.client_session.AsyncClientSession.commit_transaction() -> NoneCommit a multi-statement transaction.
method
pymongo.asynchronous.client_session.AsyncClientSession.end_session() -> NoneFinish this session.
method
pymongo.asynchronous.client_session.AsyncClientSession.has_ended() -> boolTrue if this session is finished.
class
pymongo.asynchronous.client_session.SessionOptionsOptions for a new :class:`AsyncClientSession`.
method
pymongo.asynchronous.client_session.SessionOptions.causal_consistency() -> boolWhether causal consistency is configured.
method
pymongo.asynchronous.client_session.SessionOptions.snapshot() -> Optional[bool]Whether snapshot reads are configured.
class
pymongo.asynchronous.collection.AsyncCollectionAn asynchronous Mongo collection.
method
pymongo.asynchronous.collection.AsyncCollection.create_index(keys:_IndexKeyHint, session:Optional[AsyncClientSession]=None, comment:Optional[Any]=None, **kwargs:Any) -> strCreates an index on this collection.
method
pymongo.asynchronous.collection.AsyncCollection.drop_indexes(session:Optional[AsyncClientSession]=None, comment:Optional[Any]=None, **kwargs:Any) -> NoneDrops all indexes on this collection.
method
pymongo.asynchronous.collection.AsyncCollection.drop_search_index(name:str, session:Optional[AsyncClientSession]=None, comment:Optional[Any]=None, **kwargs:Any) -> NoneDelete a search index by index name.
method
pymongo.asynchronous.collection.AsyncCollection.find(*args:Any, **kwargs:Any) -> AsyncCursor[_DocumentType]Query the database.
method
pymongo.asynchronous.collection.AsyncCollection.find_one(filter:Optional[Any]=None, *args:Any, **kwargs:Any) -> Optional[_DocumentType]Get a single document from the database.
method
pymongo.asynchronous.collection.AsyncCollection.full_name() -> strThe full name of this :class:`AsyncCollection`.
method
pymongo.asynchronous.collection.AsyncCollection.name() -> strThe name of this :class:`AsyncCollection`.
method
pymongo.asynchronous.collection.AsyncCollection.options(session:Optional[AsyncClientSession]=None, comment:Optional[Any]=None) -> MutableMapping[str, Any]Get the options set on this collection.
method
pymongo.asynchronous.collection.AsyncCollection.rename(new_name:str, session:Optional[AsyncClientSession]=None, comment:Optional[Any]=None, **kwargs:Any) -> MutableMapping[str, Any]Rename this collection.
method
pymongo.asynchronous.cursor.AsyncCursor.add_option(mask:int) -> AsyncCursor[_DocumentType]Set arbitrary query flags using a bitmask.
method
pymongo.asynchronous.cursor.AsyncCursor.batch_size(batch_size:int) -> AsyncCursor[_DocumentType]Limits the number of documents returned in one batch.
method
pymongo.asynchronous.cursor.AsyncCursor.clone() -> AsyncCursor[_DocumentType]Get a clone of this cursor.
method
pymongo.asynchronous.cursor.AsyncCursor.comment(comment:Any) -> AsyncCursor[_DocumentType]Adds a 'comment' to the cursor.
method
pymongo.asynchronous.cursor.AsyncCursor.explain() -> _DocumentTypeReturns an explain plan record for this cursor.
method
pymongo.asynchronous.cursor.AsyncCursor.limit(limit:int) -> AsyncCursor[_DocumentType]Limits the number of results to be returned by this cursor.
method
pymongo.asynchronous.cursor.AsyncCursor.max_time_ms(max_time_ms:Optional[int]) -> AsyncCursor[_DocumentType]Specifies a time limit for a query operation.
method
pymongo.asynchronous.cursor.AsyncCursor.min(spec:_Sort) -> AsyncCursor[_DocumentType]Adds ``min`` operator that specifies lower bound for specific index.
method
pymongo.asynchronous.cursor.AsyncCursor.next() -> _DocumentTypeAdvance the cursor.
method
pymongo.asynchronous.cursor.AsyncCursor.remove_option(mask:int) -> AsyncCursor[_DocumentType]Unset arbitrary query flags using a bitmask.
method
pymongo.asynchronous.cursor.AsyncCursor.retrieved() -> intThe number of documents retrieved so far.
method
pymongo.asynchronous.cursor.AsyncCursor.rewind() -> AsyncCursor[_DocumentType]Rewind this cursor to its unevaluated state.
method
pymongo.asynchronous.cursor.AsyncCursor.skip(skip:int) -> AsyncCursor[_DocumentType]Skips the first `skip` results of this cursor.
method
pymongo.asynchronous.cursor.AsyncCursor.sort(key_or_list:_Hint, direction:Optional[Union[int, str]]=None) -> AsyncCursor[_DocumentType]Sorts this cursor's results.
method
pymongo.asynchronous.cursor.AsyncCursor.where(code:Union[str, Code]) -> AsyncCursor[_DocumentType]Adds a `$where`_ clause to this query.
method
pymongo.asynchronous.database.AsyncDatabase.name() -> strThe name of this :class:`AsyncDatabase`.
class
pymongo.asynchronous.encryption.AsyncClientEncryptionExplicit client-side field level encryption.
method
pymongo.asynchronous.encryption.AsyncClientEncryption.close() -> NoneRelease resources.
method
pymongo.asynchronous.encryption.AsyncClientEncryption.decrypt(value:Binary) -> AnyDecrypt an encrypted value.
method
pymongo.asynchronous.encryption.AsyncClientEncryption.get_key(id:Binary) -> Optional[RawBSONDocument]Get a data key by id.
method
pymongo.asynchronous.encryption.AsyncClientEncryption.get_keys() -> AsyncCursor[RawBSONDocument]Get all of the data keys.
method
pymongo.asynchronous.monitor.Monitor.cancel_check() -> NoneCancel any concurrent hello check.
class
pymongo.asynchronous.pool.AsyncConnectionStore a connection with some metadata.
method
pymongo.asynchronous.pool.AsyncConnection.add_server_api(command:MutableMapping[str, Any]) -> NoneAdd server_api parameters.
method
pymongo.asynchronous.pool.AsyncConnection.authenticate(reauthenticate:bool=False) -> NoneAuthenticate to the server if needed.
method
pymongo.asynchronous.pool.AsyncConnection.close_conn(reason:Optional[str]) -> NoneClose this connection with a reason.
method
pymongo.asynchronous.pool.AsyncConnection.receive_message(request_id:Optional[int]) -> _OpMsgReceive a raw BSON message or raise ConnectionFailure.
method
pymongo.asynchronous.pool.AsyncConnection.send_cluster_time(command:MutableMapping[str, Any], session:Optional[AsyncClientSession], client:Optional[AsyncMongoClient[Any]]) -> NoneAdd $clusterTime.
method
pymongo.asynchronous.pool.AsyncConnection.send_message(message:bytes, max_doc_size:int) -> NoneSend a raw BSON message or raise ConnectionFailure.
method
pymongo.asynchronous.pool.Pool.checkout(handler:Optional[_ClientCheckout]=None) -> _PoolCheckoutGet a connection from the pool.
method
pymongo.asynchronous.pool.Pool.connect(handler:Optional[_ClientCheckout]=None) -> AsyncConnectionConnect to Mongo and return a new AsyncConnection.
method
pymongo.asynchronous.server.Server.close() -> NoneClear the connection pool and stop the monitor.
method
pymongo.asynchronous.server.Server.open() -> NoneStart monitoring, or restart after a fork.
method
pymongo.asynchronous.server.Server.request_check() -> NoneCheck the server's state soon.
method
pymongo.asynchronous.server.Server.reset(service_id:Optional[ObjectId]=None) -> NoneClear the connection pool.
class
pymongo.asynchronous.topology.TopologyMonitor a topology of one or more servers.
method
pymongo.asynchronous.topology.Topology.close() -> NoneClear pools and terminate monitors.
method
pymongo.asynchronous.topology.Topology.get_arbiters() -> set[_Address]Return set of arbiter addresses.
method
pymongo.asynchronous.topology.Topology.get_primary() -> Optional[_Address]Return primary's address or None.
method
pymongo.asynchronous.topology.Topology.get_secondaries() -> set[_Address]Return set of secondary addresses.
method
pymongo.asynchronous.topology.Topology.get_server_by_address(address:_Address) -> Optional[Server]Get a Server or None.
method
pymongo.asynchronous.topology.Topology.handle_error(address:_Address, err_ctx:_ErrorContext) -> NoneHandle an application error.
method
pymongo.asynchronous.topology.Topology.open() -> NoneStart monitoring, or restart after a fork.
method
pymongo.asynchronous.topology.Topology.pop_all_sessions() -> list[_ServerSession]Pop all session ids from the pool.
class
pymongo.auth_oidc_shared.OIDCCallbackA base class for defining OIDC callbacks.
method
pymongo.auth_oidc_shared.OIDCCallback.fetch(context:OIDCCallbackContext) -> OIDCCallbackResultConvert the given BSON value into our own type.
method
pymongo.client_options.ClientOptions.heartbeat_frequency() -> intThe monitoring frequency in seconds.
method
pymongo.client_options.ClientOptions.local_threshold_ms() -> intThe local threshold for this instance.
method
pymongo.client_options.ClientOptions.max_adaptive_retries() -> intThe configured maxAdaptiveRetries option.
method
pymongo.client_options.ClientOptions.pool_options() -> PoolOptionsA :class:`~pymongo.pool.PoolOptions` instance.
method
pymongo.client_options.ClientOptions.read_preference() -> _ServerModeA read preference instance.
method
pymongo.client_options.ClientOptions.replica_set_name() -> Optional[str]Replica set name or None.
method
pymongo.client_options.ClientOptions.server_monitoring_mode() -> strThe configured serverMonitoringMode option.
method
pymongo.collation.Collation.document() -> dict[str, Any]The document representation of this collation.
class
pymongo.common.VersionA class that can be used to compare version strings.
func
pymongo.common.clean_node(node:str) -> tuple[str, int]Split and normalize a node name from a hello response.
func
pymongo.common.has_c() -> boolIs the C extension installed?
func
pymongo.common.partition_node(node:str) -> tuple[str, int]Split a host:port string into (host, int(port)) pair.
func
pymongo.common.raise_config_error(key:str, suggestions:Optional[list[str]]=None) -> NoReturnRaise ConfigurationError with the given key name.
func
pymongo.common.validate(option:str, value:Any) -> tuple[str, Any]Generic validation function.
func
pymongo.common.validate_appname_or_none(option:str, value:Any) -> Optional[str]Validate the appname option.
func
pymongo.common.validate_auth_mechanism(option:str, value:Any) -> strValidate the authMechanism URI option.
func
pymongo.common.validate_auth_mechanism_properties(option:str, value:Any) -> dict[str, Union[bool, str]]Validate authMechanismProperties.
func
pymongo.common.validate_auto_encryption_opts_or_none(option:Any, value:Any) -> Optional[Any]Validate the driver keyword arg.
func
pymongo.common.validate_boolean_or_string(option:str, value:Any) -> boolValidates that value is True, False, 'true', or 'false'.
func
pymongo.common.validate_datetime_conversion(option:Any, value:Any) -> Optional[DatetimeConversion]Validate a DatetimeConversion string.
func
pymongo.common.validate_document_class(option:str, value:Any) -> Union[type[MutableMapping[str, Any]], type[RawBSONDocument]]Validate the document_class option.
func
pymongo.common.validate_driver_or_none(option:Any, value:Any) -> Optional[DriverInfo]Validate the driver keyword arg.
func
pymongo.common.validate_integer(option:str, value:Any) -> intValidates that 'value' is an integer (or basestring representation).
func
pymongo.common.validate_is_callable_or_none(option:Any, value:Any) -> Optional[Callable[..., Any]]Validates that 'value' is a callable.
func
pymongo.common.validate_is_mapping(option:str, value:Any) -> NoneValidate the type of method arguments that expect a document.
func
pymongo.common.validate_list(option:str, value:Any) -> list[Any]Validates that 'value' is a list.
func
pymongo.common.validate_list_or_mapping(option:Any, value:Any) -> NoneValidates that 'value' is a list or a document.
func
pymongo.common.validate_list_or_none(option:Any, value:Any) -> Optional[list[Any]]Validates that 'value' is a list or None.
func
pymongo.common.validate_non_negative_int_or_basestring(option:Any, value:Any) -> Union[int, str]Validates that 'value' is an integer or string.
func
pymongo.common.validate_non_negative_integer(option:str, value:Any) -> intValidate that 'value' is a positive integer or 0.
func
pymongo.common.validate_ok_for_replace(replacement:Mapping[str, Any]) -> NoneValidate a replacement document.
func
pymongo.common.validate_ok_for_update(update:Any) -> NoneValidate an update document.
func
pymongo.common.validate_read_preference(dummy:Any, value:Any) -> _ServerModeValidate a read preference.
func
pymongo.common.validate_read_preference_mode(dummy:Any, value:Any) -> _ServerModeValidate read preference mode for a MongoClient.
func
pymongo.common.validate_read_preference_tags(name:str, value:Any) -> list[dict[str, str]]Parse readPreferenceTags if passed as a client kwarg.
func
pymongo.common.validate_readable(option:str, value:Any) -> Optional[str]Validates that 'value' is file-like and readable.
func
pymongo.common.validate_server_api_or_none(option:Any, value:Any) -> Optional[ServerApi]Validate the server_api keyword arg.
func
pymongo.common.validate_server_monitoring_mode(option:str, value:str) -> strValidate the serverMonitoringMode option.
func
pymongo.common.validate_string(option:str, value:Any) -> strValidates that 'value' is an instance of `str`.
func
pymongo.common.validate_type_registry(option:Any, value:Any) -> Optional[TypeRegistry]Validate the type_registry option.
func
pymongo.common.validate_tzinfo(dummy:Any, value:Any) -> Optional[datetime.tzinfo]Validate the tzinfo option
func
pymongo.common.validate_uuid_representation(dummy:Any, value:Any) -> intValidate the uuid representation option selected in the URI.
class
pymongo.driver_info.DriverInfoInfo about a driver wrapping PyMongo.
class
pymongo.encryption_options.PrefixOpts**BETA** Options for prefix text queries.
class
pymongo.encryption_options.SubstringOpts**BETA** Options for substring text queries.
class
pymongo.encryption_options.SuffixOpts**BETA** Options for suffix text queries.
class
pymongo.errors.BulkWriteErrorException class for bulk write errors.
class
pymongo.errors.ClientBulkWriteExceptionException class for client-level bulk write errors.
class
pymongo.errors.CollectionInvalidRaised when collection validation fails.
class
pymongo.errors.ConfigurationErrorRaised when something is incorrectly configured.
class
pymongo.errors.EncryptionErrorRaised when encryption or decryption fails.
class
pymongo.errors.InvalidNameRaised when an invalid name is used.
class
pymongo.errors.InvalidOperationRaised when a client attempts to perform an invalid operation.
class
pymongo.errors.InvalidURIRaised when trying to parse an invalid mongodb URI.
class
pymongo.errors.NotPrimaryErrorThe server responded "not primary" or "node is recovering".
class
pymongo.errors.OperationFailureRaised when a database operation fails.
method
pymongo.errors.OperationFailure.code() -> Optional[int]The error code returned by the server, if any.
class
pymongo.errors.ProtocolErrorRaised for failures related to the wire protocol.
class
pymongo.errors.PyMongoErrorBase class for all PyMongo exceptions.
method
pymongo.errors.PyMongoError.has_error_label(label:str) -> boolReturn True if this error contains the given label.
method
pymongo.errors.PyMongoError.timeout() -> boolTrue if this error was caused by a timeout.
class
pymongo.errors.WTimeoutErrorRaised when a database operation times out (i.e.
class
pymongo.errors.WriteConcernErrorBase exception type for errors raised due to write concern.
class
pymongo.event_loggers.CommandLoggerA simple listener that logs command events.
class
pymongo.event_loggers.HeartbeatLoggerA simple listener that logs server heartbeat events.
class
pymongo.event_loggers.ServerLoggerA simple listener that logs server discovery events.
class
pymongo.event_loggers.TopologyLoggerA simple listener that logs server topology events.
class
pymongo.hello.HelloParse a hello response from the server.
method
pymongo.hello.Hello.document() -> _DocumentTypeThe complete hello command response document.
method
pymongo.hello.Hello.replica_set_name() -> Optional[str]Replica set name or None.
method
pymongo.hello.Hello.speculative_authenticate() -> Optional[Mapping[str, Any]]The speculativeAuthenticate field.
method
pymongo.hello.Hello.tags() -> Mapping[str, Any]Replica set member tags or empty dict.
func
pymongo.max_staleness_selectors.select(max_staleness:int, selection:Selection) -> SelectionApply max_staleness, in seconds, to a Selection.
class
pymongo.monitoring.CommandFailedEventEvent published when a command fails.
method
pymongo.monitoring.CommandFailedEvent.duration_micros() -> intThe duration of this operation in microseconds.
method
pymongo.monitoring.CommandFailedEvent.failure() -> _DocumentOutThe server failure document for this operation.
class
pymongo.monitoring.CommandListenerAbstract base class for command listeners.
method
pymongo.monitoring.CommandListener.failed(event:CommandFailedEvent) -> NoneAbstract method to handle a `CommandFailedEvent`.
method
pymongo.monitoring.CommandListener.started(event:CommandStartedEvent) -> NoneAbstract method to handle a `CommandStartedEvent`.
method
pymongo.monitoring.CommandListener.succeeded(event:CommandSucceededEvent) -> NoneAbstract method to handle a `CommandSucceededEvent`.
class
pymongo.monitoring.CommandStartedEventEvent published when a command starts.
method
pymongo.monitoring.CommandStartedEvent.command() -> _DocumentOutThe command document.
class
pymongo.monitoring.CommandSucceededEventEvent published when a command succeeds.
method
pymongo.monitoring.CommandSucceededEvent.duration_micros() -> intThe duration of this operation in microseconds.
method
pymongo.monitoring.CommandSucceededEvent.reply() -> _DocumentOutThe server failure document for this operation.
class
pymongo.monitoring.ConnectionClosedEventPublished when a Connection is closed.
method
pymongo.monitoring.ConnectionClosedEvent.reason() -> strA reason explaining why this connection was closed.
class
pymongo.monitoring.ConnectionPoolListenerAbstract base class for connection pool listeners.
method
pymongo.monitoring.ConnectionPoolListener.pool_cleared(event:PoolClearedEvent) -> NoneAbstract method to handle a `PoolClearedEvent`.
method
pymongo.monitoring.ConnectionPoolListener.pool_closed(event:PoolClosedEvent) -> NoneAbstract method to handle a `PoolClosedEvent`.
method
pymongo.monitoring.ConnectionPoolListener.pool_created(event:PoolCreatedEvent) -> NoneAbstract method to handle a :class:`PoolCreatedEvent`.
method
pymongo.monitoring.ConnectionPoolListener.pool_ready(event:PoolReadyEvent) -> NoneAbstract method to handle a :class:`PoolReadyEvent`.
class
pymongo.monitoring.PoolClearedEventPublished when a Connection Pool is cleared.
method
pymongo.monitoring.PoolClearedEvent.service_id() -> Optional[ObjectId]Connections with this service_id are cleared.
class
pymongo.monitoring.PoolClosedEventPublished when a Connection Pool is closed.
class
pymongo.monitoring.PoolCreatedEventPublished when a Connection Pool is created.
class
pymongo.monitoring.PoolReadyEventPublished when a Connection Pool is marked ready.
class
pymongo.monitoring.ServerClosedEventPublished when server is closed.
class
pymongo.monitoring.ServerDescriptionChangedEventPublished when server description changes.
class
pymongo.monitoring.ServerHeartbeatListenerAbstract base class for server heartbeat listeners.
class
pymongo.monitoring.ServerHeartbeatStartedEventPublished when a heartbeat is started.
class
pymongo.monitoring.ServerHeartbeatSucceededEventFired when the server heartbeat succeeds.
method
pymongo.monitoring.ServerHeartbeatSucceededEvent.awaited() -> boolWhether the heartbeat was awaited.
method
pymongo.monitoring.ServerHeartbeatSucceededEvent.duration() -> floatThe duration of this heartbeat in microseconds.
class
pymongo.monitoring.ServerListenerAbstract base class for server listeners.
method
pymongo.monitoring.ServerListener.closed(event:ServerClosedEvent) -> NoneAbstract method to handle a `ServerClosedEvent`.
method
pymongo.monitoring.ServerListener.opened(event:ServerOpeningEvent) -> NoneAbstract method to handle a `ServerOpeningEvent`.
class
pymongo.monitoring.ServerOpeningEventPublished when server is initialized.
class
pymongo.monitoring.TopologyClosedEventPublished when the topology is closed.
class
pymongo.monitoring.TopologyDescriptionChangedEventPublished when the topology description changes.
class
pymongo.monitoring.TopologyEventBase class for topology description events.
class
pymongo.monitoring.TopologyListenerAbstract base class for topology monitoring listeners.
method
pymongo.monitoring.TopologyListener.closed(event:TopologyClosedEvent) -> NoneAbstract method to handle a `TopologyClosedEvent`.
method
pymongo.monitoring.TopologyListener.opened(event:TopologyOpenedEvent) -> NoneAbstract method to handle a `TopologyOpenedEvent`.
class
pymongo.monitoring.TopologyOpenedEventPublished when the topology is initialized.
func
pymongo.monitoring.register(listener:_EventListener) -> NoneRegister a global event listener.
func
pymongo.network_layer.receive_message(conn:Connection, request_id:Optional[int], max_message_size:int=MAX_MESSAGE_SIZE) -> _OpMsgReceive a raw BSON message or raise socket.error.
class
pymongo.operations.DeleteManyRepresents a delete_many operation.
class
pymongo.operations.DeleteOneRepresents a delete_one operation.
class
pymongo.operations.IndexModelRepresents an index to create.
class
pymongo.operations.InsertOneRepresents an insert_one operation.
class
pymongo.operations.ReplaceOneRepresents a replace_one operation.
class
pymongo.operations.SearchIndexModelRepresents a search index to create.
method
pymongo.operations.SearchIndexModel.document() -> Mapping[str, Any]The document for this index.
class
pymongo.operations.UpdateManyRepresents an update_many operation.
class
pymongo.operations.UpdateOneRepresents an update_one operation.
class
pymongo.read_preferences.MovingAverageTracks an exponentially-weighted moving average.
class
pymongo.read_preferences.NearestNearest read preference.
class
pymongo.read_preferences.PrimaryPrimary read preference.
class
pymongo.read_preferences.PrimaryPreferredPrimaryPreferred read preference.
class
pymongo.read_preferences.SecondarySecondary read preference.
class
pymongo.read_preferences.SecondaryPreferredSecondaryPreferred read preference.
func
pymongo.read_preferences.read_pref_mode_from_name(name:str) -> intGet the read preference mode from mongos/uri name.
method
pymongo.response.Response.address() -> _Address(host, port) of the source server.
method
pymongo.response.Response.data() -> _OpMsgServer response's raw BSON bytes.
method
pymongo.response.Response.docs() -> Sequence[Mapping[str, Any]]The decoded document(s).
method
pymongo.response.Response.duration() -> Optional[timedelta]The duration of the operation.
method
pymongo.response.Response.from_command() -> boolIf the response is a result from a db command.
method
pymongo.response.Response.request_id() -> intThe request id of this operation.
method
pymongo.results.ClientBulkWriteResult.has_verbose_results() -> boolWhether the returned results should be verbose.
method
pymongo.results.DeleteResult.deleted_count() -> intThe number of documents deleted.
method
pymongo.results.DeleteResult.raw_result() -> Mapping[str, Any]The raw result document returned by the server.
method
pymongo.results.UpdateResult.did_upsert() -> boolWhether an upsert took place.
method
pymongo.results.UpdateResult.matched_count() -> intThe number of documents matched for this update.
method
pymongo.results.UpdateResult.modified_count() -> intThe number of documents modified.
method
pymongo.results.UpdateResult.raw_result() -> Optional[Mapping[str, Any]]The raw result document returned by the server.
func
pymongo.saslprep.saslprep(data:Any, prohibit_unassigned_code_points:Optional[bool]=True) -> AnySASLprep dummy
class
pymongo.server_api.ServerApiMongoDB Stable API.
method
pymongo.server_api.ServerApi.deprecation_errors() -> Optional[bool]The API deprecation errors setting.
method
pymongo.server_api.ServerApi.strict() -> Optional[bool]The API strict mode setting.
method
pymongo.server_api.ServerApi.version() -> strThe API version setting.
class
pymongo.server_description.ServerDescriptionImmutable representation of one server.
method
pymongo.server_description.ServerDescription.address() -> _AddressThe address (host, port) of this server.
method
pymongo.server_description.ServerDescription.min_round_trip_time() -> floatThe min latency from the most recent samples.
method
pymongo.server_description.ServerDescription.replica_set_name() -> Optional[str]Replica set name or None.
method
pymongo.server_description.ServerDescription.round_trip_time() -> Optional[float]The current average latency or None.
method
pymongo.server_description.ServerDescription.server_type() -> intThe type of this server.
method
pymongo.server_description.ServerDescription.server_type_name() -> strThe server type as a human readable string.
class
pymongo.server_selectors.SelectionInput or output of a server selector function.
func
pymongo.server_selectors.apply_single_tag_set(tag_set:TagSet, selection:Selection) -> SelectionAll servers matching one tag set.
func
pymongo.server_selectors.apply_tag_sets(tag_sets:TagSets, selection:Selection) -> SelectionAll servers match a list of tag sets.
func
pymongo.server_selectors.member_with_tags_server_selector(tag_sets:TagSets, selection:Selection) -> SelectionAll near-enough members matching the tag sets.
func
pymongo.server_selectors.secondary_with_tags_server_selector(tag_sets:TagSets, selection:Selection) -> SelectionAll near-enough secondaries matching the tag sets.
func
pymongo.server_selectors.writable_preferred_server_selector(selection:Selection) -> SelectionLike PrimaryPreferred but doesn't use tags or latency.
func
pymongo.synchronous.auth.authenticate(credentials:MongoCredential, conn:Connection, reauthenticate:bool=False) -> NoneAuthenticate connection.
class
pymongo.synchronous.client_session.ClientSessionA session for ordering sequential operations.
method
pymongo.synchronous.client_session.ClientSession.abort_transaction() -> NoneAbort a multi-statement transaction.
method
pymongo.synchronous.client_session.ClientSession.advance_cluster_time(cluster_time:Mapping[str, Any]) -> NoneUpdate the cluster time for this session.
method
pymongo.synchronous.client_session.ClientSession.advance_operation_time(operation_time:Timestamp) -> NoneUpdate the operation time for this session.
method
pymongo.synchronous.client_session.ClientSession.commit_transaction() -> NoneCommit a multi-statement transaction.
method
pymongo.synchronous.client_session.ClientSession.end_session() -> NoneFinish this session.
method
pymongo.synchronous.client_session.ClientSession.has_ended() -> boolTrue if this session is finished.
class
pymongo.synchronous.client_session.SessionOptionsOptions for a new :class:`ClientSession`.
method
pymongo.synchronous.client_session.SessionOptions.causal_consistency() -> boolWhether causal consistency is configured.
method
pymongo.synchronous.client_session.SessionOptions.snapshot() -> Optional[bool]Whether snapshot reads are configured.
class
pymongo.synchronous.collection.CollectionA Mongo collection.
method
pymongo.synchronous.collection.Collection.create_index(keys:_IndexKeyHint, session:Optional[ClientSession]=None, comment:Optional[Any]=None, **kwargs:Any) -> strCreates an index on this collection.
method
pymongo.synchronous.collection.Collection.drop_indexes(session:Optional[ClientSession]=None, comment:Optional[Any]=None, **kwargs:Any) -> NoneDrops all indexes on this collection.
method
pymongo.synchronous.collection.Collection.drop_search_index(name:str, session:Optional[ClientSession]=None, comment:Optional[Any]=None, **kwargs:Any) -> NoneDelete a search index by index name.
method
pymongo.synchronous.collection.Collection.find(*args:Any, **kwargs:Any) -> Cursor[_DocumentType]Query the database.
method
pymongo.synchronous.collection.Collection.find_one(filter:Optional[Any]=None, *args:Any, **kwargs:Any) -> Optional[_DocumentType]Get a single document from the database.
method
pymongo.synchronous.collection.Collection.full_name() -> strThe full name of this :class:`Collection`.
method
pymongo.synchronous.collection.Collection.name() -> strThe name of this :class:`Collection`.
method
pymongo.synchronous.collection.Collection.options(session:Optional[ClientSession]=None, comment:Optional[Any]=None) -> MutableMapping[str, Any]Get the options set on this collection.
method
pymongo.synchronous.collection.Collection.rename(new_name:str, session:Optional[ClientSession]=None, comment:Optional[Any]=None, **kwargs:Any) -> MutableMapping[str, Any]Rename this collection.
class
pymongo.synchronous.command_cursor.CommandCursorA cursor / iterator over command cursors.
method
pymongo.synchronous.command_cursor.CommandCursor.next() -> _DocumentTypeAdvance the cursor.
method
pymongo.synchronous.cursor.Cursor.add_option(mask:int) -> Cursor[_DocumentType]Set arbitrary query flags using a bitmask.
method
pymongo.synchronous.cursor.Cursor.batch_size(batch_size:int) -> Cursor[_DocumentType]Limits the number of documents returned in one batch.
method
pymongo.synchronous.cursor.Cursor.clone() -> Cursor[_DocumentType]Get a clone of this cursor.
method
pymongo.synchronous.cursor.Cursor.comment(comment:Any) -> Cursor[_DocumentType]Adds a 'comment' to the cursor.
method
pymongo.synchronous.cursor.Cursor.explain() -> _DocumentTypeReturns an explain plan record for this cursor.
method
pymongo.synchronous.cursor.Cursor.limit(limit:int) -> Cursor[_DocumentType]Limits the number of results to be returned by this cursor.
method
pymongo.synchronous.cursor.Cursor.max_time_ms(max_time_ms:Optional[int]) -> Cursor[_DocumentType]Specifies a time limit for a query operation.
method
pymongo.synchronous.cursor.Cursor.next() -> _DocumentTypeAdvance the cursor.
method
pymongo.synchronous.cursor.Cursor.remove_option(mask:int) -> Cursor[_DocumentType]Unset arbitrary query flags using a bitmask.
method
pymongo.synchronous.cursor.Cursor.retrieved() -> intThe number of documents retrieved so far.
method
pymongo.synchronous.cursor.Cursor.rewind() -> Cursor[_DocumentType]Rewind this cursor to its unevaluated state.
method
pymongo.synchronous.cursor.Cursor.skip(skip:int) -> Cursor[_DocumentType]Skips the first `skip` results of this cursor.
method
pymongo.synchronous.cursor.Cursor.sort(key_or_list:_Hint, direction:Optional[Union[int, str]]=None) -> Cursor[_DocumentType]Sorts this cursor's results.
method
pymongo.synchronous.cursor.Cursor.where(code:Union[str, Code]) -> Cursor[_DocumentType]Adds a `$where`_ clause to this query.
method
pymongo.synchronous.database.Database.aggregate(pipeline:_Pipeline, session:Optional[ClientSession]=None, **kwargs:Any) -> CommandCursor[_DocumentType]Perform a database-level aggregation.
method
pymongo.synchronous.database.Database.name() -> strThe name of this :class:`Database`.
class
pymongo.synchronous.encryption.ClientEncryptionExplicit client-side field level encryption.
method
pymongo.synchronous.encryption.ClientEncryption.close() -> NoneRelease resources.
method
pymongo.synchronous.encryption.ClientEncryption.decrypt(value:Binary) -> AnyDecrypt an encrypted value.
method
pymongo.synchronous.encryption.ClientEncryption.get_key(id:Binary) -> Optional[RawBSONDocument]Get a data key by id.
method
pymongo.synchronous.encryption.ClientEncryption.get_keys() -> Cursor[RawBSONDocument]Get all of the data keys.
func
pymongo.synchronous.mongo_client.MongoClient.option_repr(option:str, value:Any) -> strFix options whose __repr__ isn't usable in a constructor.
method
pymongo.synchronous.monitor.Monitor.cancel_check() -> NoneCancel any concurrent hello check.
class
pymongo.synchronous.pool.ConnectionStore a connection with some metadata.
method
pymongo.synchronous.pool.Connection.add_server_api(command:MutableMapping[str, Any]) -> NoneAdd server_api parameters.
method
pymongo.synchronous.pool.Connection.authenticate(reauthenticate:bool=False) -> NoneAuthenticate to the server if needed.
method
pymongo.synchronous.pool.Connection.close_conn(reason:Optional[str]) -> NoneClose this connection with a reason.
method
pymongo.synchronous.pool.Connection.receive_message(request_id:Optional[int]) -> _OpMsgReceive a raw BSON message or raise ConnectionFailure.
method
pymongo.synchronous.pool.Connection.send_cluster_time(command:MutableMapping[str, Any], session:Optional[ClientSession], client:Optional[MongoClient[Any]]) -> NoneAdd $clusterTime.
method
pymongo.synchronous.pool.Connection.send_message(message:bytes, max_doc_size:int) -> NoneSend a raw BSON message or raise ConnectionFailure.
method
pymongo.synchronous.pool.Connection.validate_session(client:Optional[MongoClient[Any]], session:Optional[ClientSession]) -> NoneValidate this session before use with client.
method
pymongo.synchronous.pool.Pool.checkin(conn:Connection) -> NoneReturn the connection to the pool, or if it's closed discard it.
method
pymongo.synchronous.pool.Pool.checkout(handler:Optional[_ClientCheckout]=None) -> _PoolCheckoutGet a connection from the pool.
method
pymongo.synchronous.pool.Pool.connect(handler:Optional[_ClientCheckout]=None) -> ConnectionConnect to Mongo and return a new Connection.
method
pymongo.synchronous.server.Server.close() -> NoneClear the connection pool and stop the monitor.
method
pymongo.synchronous.server.Server.open() -> NoneStart monitoring, or restart after a fork.
method
pymongo.synchronous.server.Server.request_check() -> NoneCheck the server's state soon.
method
pymongo.synchronous.server.Server.reset(service_id:Optional[ObjectId]=None) -> NoneClear the connection pool.
class
pymongo.synchronous.topology.TopologyMonitor a topology of one or more servers.
method
pymongo.synchronous.topology.Topology.close() -> NoneClear pools and terminate monitors.
method
pymongo.synchronous.topology.Topology.data_bearing_servers() -> list[ServerDescription]Return a list of all data-bearing servers.
method
pymongo.synchronous.topology.Topology.get_arbiters() -> set[_Address]Return set of arbiter addresses.
method
pymongo.synchronous.topology.Topology.get_primary() -> Optional[_Address]Return primary's address or None.
この情報について
掲載しているシグネチャは mongodb/mongo-python-driver の公開ソースコードを
Python の ast モジュールで静的解析し、引数名・デフォルト値・
型注釈・戻り値型をそのまま抽出したものです。実装コードは保存していません。
詳しくは仕組みの解説をご覧ください。