Using SQL in Airflow DAGs

Abdulkadir Karakus
4 min readJul 21, 2024

Apache Airflow is a powerful tool for programmatically managing workflows. It is widely used by data engineers and analysts to automate and monitor workflows. In this article, we will explore the steps to create a Directed Acyclic Graph (DAG) in Airflow using MySQL.

Photo by Caspar Camille Rubin on Unsplash

Step 1: Installing Airflow

The simplest way to install Airflow is by using pip. You can install Airflow by running the following command in your terminal or command prompt:

pip install apache-airflow

Additionally, you might want to install specific versions of Airflow. For example, to install Airflow version 2.5.0, use the following command:

pip install apache-airflow==2.5.0

To verify that Airflow has been successfully installed, you can run the following command:

airflow version

Step 2: Airflow Configuration

After installing Airflow, you need to configure it by editing the `airflow.cfg` file. In this file, you can set the database connection details and other necessary settings. By default, Airflow uses SQLite, but for production environments, it is recommended to use a more robust database such as PostgreSQL or MySQL.

--

--