Apache Airflow Providers Cloudant

raw JSON →
4.3.4 verified Mon Apr 27 auth: no python

Apache Airflow provider for Cloudant (a hosted Apache CouchDB service). Current version 4.3.4, compatible with Airflow >=2.6 and Python >=3.10. Released approximately monthly.

pip install apache-airflow-providers-cloudant
error airflow.exceptions.ConnectionNotFoundException: The conn_id `cloudant_default` isn't defined
cause The Cloudant connection is not configured in Airflow.
fix
Define a connection in Airflow UI or via environment variable: export AIRFLOW_CONN_CLOUDANT_DEFAULT='cloudant://user:pass@account.cloudant.com:443/my_database'
error ImportError: cannot import name 'CloudantHook' from 'airflow.providers.cloudant.hooks'
cause Installed version is too old (pre-4.0.0) or import path is incorrect.
fix
Upgrade to the latest version and use 'from airflow.providers.cloudant.hooks.cloudant import CloudantHook'.
error urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='account.cloudant.com', port=443): Max retries exceeded with url: /my_database/ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at ...>: Failed to establish a new connection: [Errno -2] Name or service not known'))
cause Hostname in connection is incorrect (missing scheme or wrong domain).
fix
Ensure the host in the connection includes 'https://' and the full domain (e.g., 'https://account.cloudant.com').
gotcha The Cloudant connection type has changed in recent versions. Use 'cloudant' as the connection type, not 'http' or 'couchdb'. The host field should contain the full URL (e.g., https://account.cloudant.com).
fix Set connection type to 'cloudant' and host to 'https://<account>.cloudant.com'.
breaking Breaking change: In version 4.0.0, the provider was restructured. Old imports like 'from airflow.contrib.hooks.cloudant_hook import CloudantHook' no longer work.
fix Use new import paths: 'from airflow.providers.cloudant.hooks.cloudant import CloudantHook'.
deprecated The 'cloudant' package (the Python client library) is now in maintenance mode. The provider uses it internally, but you may need to pin versions if you see compatibility issues with future Airflow releases.
fix Check the pinned version of 'cloudant' in the provider's dependencies if you encounter issues. Alternatively, consider migrating to the official CouchDB client.
pip install apache-airflow[cloudant]

Minimal DAG that creates a document in Cloudant. Requires a Cloudant connection defined in Airflow with the 'cloudant_default' conn_id.

from datetime import datetime
from airflow import DAG
from airflow.providers.cloudant.hooks.cloudant import CloudantHook
from airflow.providers.cloudant.operators.cloudant import CloudantCreateDocumentOperator

default_args = {
    'owner': 'airflow',
    'start_date': datetime(2024, 1, 1),
}

with DAG('cloudant_example', default_args=default_args, schedule_interval=None) as dag:
    create_doc = CloudantCreateDocumentOperator(
        task_id='create_doc',
        cloudant_conn_id='cloudant_default',
        database='my_database',
        doc={'name': 'example', 'value': 42},
    )