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

Function _detect_external_db

pymongo/synchronous/mongo_client.py:3058–3080  ·  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

3056
3057
3058def _detect_external_db(entity: str) -> bool:
3059 """Detects external database hosts and logs an informational message at the INFO level."""
3060 entity = entity.lower()
3061 cosmos_db_hosts = [".cosmos.azure.com"]
3062 document_db_hosts = [".docdb.amazonaws.com", ".docdb-elastic.amazonaws.com"]
3063
3064 for host in cosmos_db_hosts:
3065 if entity.endswith(host):
3066 _log_or_warn(
3067 _CLIENT_LOGGER,
3068 "You appear to be connected to a CosmosDB cluster. For more information regarding feature "
3069 "compatibility and support please visit https://www.mongodb.com/supportability/cosmosdb",
3070 )
3071 return True
3072 for host in document_db_hosts:
3073 if entity.endswith(host):
3074 _log_or_warn(
3075 _CLIENT_LOGGER,
3076 "You appear to be connected to a DocumentDB cluster. For more information regarding feature "
3077 "compatibility and support please visit https://www.mongodb.com/supportability/documentdb",
3078 )
3079 return True
3080 return False
3081
3082
3083if _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