Connecting to a Yandex Managed Service for Apache Airflow™ database
Written by
Updated at October 23, 2025
Warning
This guide is suitable for Apache Airflow™ 3.0 and lower.
You can connect to a Managed Service for Apache Airflow™ database using software and update connection data using a directed acyclic graph (DAG).
Prepare the DAG file and run the graph
-
Create a local file named
update_connections.pyand paste the following script to it:import json from airflow.decorators import dag, task from airflow.settings import Session from airflow.models import Connection @dag(schedule=None) def update_connections(): @task def update_connections_task(): with Session() as session: connections = session.query(Connection) for conn in connections: extra = conn.extra_dejson print(f"extra: {extra}") update_count = extra.get('update_count', 0) extra['update_count'] = update_count + 1 conn.set_extra(json.dumps(extra)) session.add(conn) session.commit() update_connections_task() update_connections() -
Upload the
update_connections.pyDAG file to the bucket you created earlier. This will automatically create a graph with the same name in the Apache Airflow™ web interface. -
Make sure a new graph named
update_connectionshas appeared in the DAGs section.It may take a few minutes to load a DAG file from the bucket.
-
To run the graph, click
in the line with its name.
Check the result
To check the result in the Apache Airflow™ web interface:
- In the DAGs section, click
update_connections. - Go to the Graph section.
- Select update_connections_task.
- Go to Logs.
- Make sure the logs contain a list of updated connections. This means the query was successful.