{"id":14829,"library":"pydocumentdb","title":"Azure DocumentDB Python SDK (Legacy)","description":"This is the legacy Python SDK for Azure DocumentDB, which was rebranded to Azure Cosmos DB. This `pydocumentdb` package is no longer maintained and has been superseded by the `azure-cosmos` package. Users should migrate to `azure-cosmos` for current development. The last stable version released under this name was 2.3.5.","status":"abandoned","version":"2.3.5","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-documentdb-python","tags":["azure","documentdb","nosql","database","legacy","abandoned","cosmosdb"],"install":[{"cmd":"pip install pydocumentdb","lang":"bash","label":"Install legacy pydocumentdb"},{"cmd":"pip install azure-cosmos","lang":"bash","label":"Install modern Azure Cosmos DB SDK (recommended)"}],"dependencies":[],"imports":[{"symbol":"DocumentClient","correct":"from pydocumentdb.document_client import DocumentClient"},{"symbol":"documents (enums)","correct":"from pydocumentdb import documents"}],"quickstart":{"code":"import os\nfrom pydocumentdb.document_client import DocumentClient\n\n# These environment variables would be for an *old* DocumentDB account.\n# Modern Azure Cosmos DB accounts use the azure-cosmos SDK.\nHOST = os.environ.get(\"DOCUMENTDB_HOST\", \"https://your-old-documentdb-account.documents.azure.com:443/\")\nMASTER_KEY = os.environ.get(\"DOCUMENTDB_MASTER_KEY\", \"YOUR_OLD_MASTER_KEY\")\n\nif not HOST or not MASTER_KEY or HOST == \"https://your-old-documentdb-account.documents.azure.com:443/\":\n    print(\"Warning: Skipping DocumentDB client init. Please set DOCUMENTDB_HOST and DOCUMENTDB_MASTER_KEY for an *old* DocumentDB account.\")\nelse:\n    try:\n        client = DocumentClient(HOST, {'masterKey': MASTER_KEY})\n        print(f\"Successfully initialized legacy DocumentDB client for host: {HOST}\")\n        # Example: Read databases (requires an active old DocumentDB account)\n        # databases = list(client.ReadDatabases())\n        # print(f\"Found {len(databases)} databases.\")\n    except Exception as e:\n        print(f\"Error initializing legacy DocumentDB client: {e}\")\n","lang":"python","description":"Shows how to initialize the legacy DocumentDB client. This code is for the `pydocumentdb` package, which is no longer maintained. Users are strongly advised to migrate to `azure-cosmos` for any new development or existing applications connecting to Azure Cosmos DB."},"warnings":[{"fix":"Migrate your code to use the `azure-cosmos` package. Refer to Azure Cosmos DB documentation for migration guides and updated APIs (e.g., `CosmosClient` instead of `DocumentClient`).","message":"The `pydocumentdb` library is officially abandoned and has been replaced by `azure-cosmos`. No new features, bug fixes, or security updates are being released for `pydocumentdb`.","severity":"breaking","affected_versions":"All versions"},{"fix":"Use the `azure-cosmos` package to connect to Azure Cosmos DB accounts. Ensure your connection strings and authentication methods align with the current Azure SDK for Python.","message":"Connecting to modern Azure Cosmos DB accounts using `pydocumentdb` will likely fail or have limited functionality, as the API versions, authentication methods, and underlying protocols have evolved significantly.","severity":"gotcha","affected_versions":"2.x.x"},{"fix":"Upgrade your Python environment to 3.7+ and use the `azure-cosmos` SDK for current Azure Cosmos DB interactions.","message":"While `pydocumentdb` might have worked with Python 2, modern Azure SDKs (including `azure-cosmos`) only support Python 3.7+. Attempting to use `pydocumentdb` with Python 2 is unsupported and discouraged.","severity":"deprecated","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"If you intend to use the legacy SDK, run `pip install pydocumentdb`. If you intend to use the modern SDK (recommended), install `azure-cosmos` (`pip install azure-cosmos`) and update your imports and code accordingly.","cause":"Attempting to import `pydocumentdb` without installing it, or trying to use `pydocumentdb` code after installing only `azure-cosmos`.","error":"ModuleNotFoundError: No module named 'pydocumentdb'"},{"fix":"Ensure your import statement is `from pydocumentdb.document_client import DocumentClient`. For modern Cosmos DB, use `from azure.cosmos import CosmosClient` from the `azure-cosmos` package.","cause":"Incorrect import statement for the `DocumentClient` class, or trying to use `azure-cosmos` import patterns with the `pydocumentdb` package.","error":"AttributeError: module 'pydocumentdb' has no attribute 'DocumentClient'"},{"fix":"First, verify your master key and host URL are correct for the legacy DocumentDB account. More importantly, consider migrating to the `azure-cosmos` package, as `pydocumentdb` is not compatible with all modern Cosmos DB features and authentication, and its connection details may differ.","cause":"Likely attempting to connect to a modern Azure Cosmos DB account using the legacy `pydocumentdb` SDK, which uses outdated authentication methods, or an incorrect master key/connection details for an old DocumentDB account.","error":"pydocumentdb.errors.DocumentDBClientException: {\"code\":\"Unauthorized\",\"message\":\"The input authorization token can't serve the request. Please check the authorization token and retry.\"...}"}],"ecosystem":"pypi"}