MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / _detect_external_db

Function _detect_external_db

pymongo/asynchronous/mongo_client.py:3068–3090  ·  view source on GitHub ↗

Detects external database hosts and logs an informational message at the INFO level.

(entity: str)

Source from the content-addressed store, hash-verified

3066
3067
3068def _detect_external_db(entity: str) -> bool:
3069 """Detects external database hosts and logs an informational message at the INFO level."""
3070 entity = entity.lower()
3071 cosmos_db_hosts = [".cosmos.azure.com"]
3072 document_db_hosts = [".docdb.amazonaws.com", ".docdb-elastic.amazonaws.com"]
3073
3074 for host in cosmos_db_hosts:
3075 if entity.endswith(host):
3076 _log_or_warn(
3077 _CLIENT_LOGGER,
3078 "You appear to be connected to a CosmosDB cluster. For more information regarding feature "
3079 "compatibility and support please visit https://www.mongodb.com/supportability/cosmosdb",
3080 )
3081 return True
3082 for host in document_db_hosts:
3083 if entity.endswith(host):
3084 _log_or_warn(
3085 _CLIENT_LOGGER,
3086 "You appear to be connected to a DocumentDB cluster. For more information regarding feature "
3087 "compatibility and support please visit https://www.mongodb.com/supportability/documentdb",
3088 )
3089 return True
3090 return False
3091
3092
3093if _HAS_REGISTER_AT_FORK:

Callers 2

__init__Method · 0.70
_resolve_srvMethod · 0.70

Calls 1

_log_or_warnFunction · 0.90

Tested by

no test coverage detected