liveBook · Manning

Get_connection

As explained in Data Pipelines with Apache Airflow, Second Edition

get_connection is a BaseHook method that retrieves a stored Airflow connection by connection identifier.

get_connection is a BaseHook method that retrieves an Airflow connection by identifier from the metastore. Custom hooks use the returned configuration to obtain schema, host, port, login, and password values. section 9.2.1

MovielensHook configuration

After creating a connection with identifier movielens, a hook retrieves it with config = self.get_connection(self._conn_id), then constructs the API base URL and authenticated session from config.

How Data Pipelines with Apache Airflow, Second Edition covers it

How deep it goes
Explains metastore retrieval, field usage, defaults, authentication, and caching, but not metastore internals.
Examples
Uses a Movielens API connection with HTTP schema, host, port 8081, and airflow credentials.
What it assumes
Assumes familiarity with Airflow BaseHook, connection identifiers, and creating connections in the Airflow web interface.
What you can do after
Build a custom hook that retrieves Airflow connection settings and uses them to create an authenticated, reusable API session.
How it connects
Connects BaseHook, custom hooks, Airflow connections, the metastore, authentication, and API sessions.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Pipelines with Apache Airflow, Second Edition. The section links point to the parts of the book it draws on.