A connection holds how to reach an outside system: type, host, port, login, password, schema (often the database name) and extra settings. Code refers to it only by its conn_id, so credentials never appear in the Dag file, in git or in logs.
Hooks and operators take the id (conn_id="marigold_warehouse") and look the connection up when the task runs. In your own code use Connection.get("marigold_warehouse") from airflow.sdk. A missing id fails the task with The conn_id ... isn't defined.
Create connections on Admin > Connections, from the terminal, or as an environment variable:
airflow connections add marigold_warehouse \
--conn-uri 'postgresql://loader:[email protected]:5432/analytics'
export AIRFLOW_CONN_MARIGOLD_WAREHOUSE='postgresql://loader:[email protected]:5432/analytics'
In a URI the scheme is the type, then login and password, host, port, and the path is the schema.
A connection read inside a task. The password is there too, but never print it.