🗓️Airflow Connection
Also known as Connection (Airflow), conn_id, AIRFLOW_CONN
A saved set of login details for an outside system. Tasks find it by name.
Think of it like
It is like a saved contact on your phone. You tap a name, and the phone knows the number.
Example
The shop's database is saved as a connection named shop_db. Every DAG that reads orders asks for shop_db. When the password changes, it changes in one place.
Why it matters
Passwords stay out of the code and out of git. One change to a connection fixes every DAG that uses it.
Definition
Example code
bash
export AIRFLOW_CONN_SHOP_DB='postgres://etl:secret@db.example.com:5432/shop'Common mistake
Key takeaways
- 1Stored once. Host, login and password.
- 2Found by name. Tasks ask for the conn_id.
- 3Out of the code. No secrets in DAG files.