Making Airlflow talks with MS SQL Server
Contents
MS SQL Server Operator on Airflow
Introduction
Now days multicloud idea is becoming more common than ever so it’s not weird to wondering how to use Airflow to connect MS SQL Server relational database.
Of course, you can use GKEPodOperator and setup a docker image to support this operation but guess what? There is an straighforward way to do it using MsSqlOperator
operator and I will try to show you how-to.
This is how will looks like in your DAG script
Motivation
This is how your task will look in action
|
|
Break-down
Cool! isn’t it?
So we have following class header for MsSqlOperator
|
|
and you need to:
- Install operator modules on Airflow
- Create a connection reference and
- Instantiate a
MsSQLOperator
operator
Setup Airflow
In ordert to use MsSQLOperator
you should install following modules (tested in Airflow 10.1.12
)
|
|
Create a connection reference
Let’s talk about mssql_con_id
parameter, you can create a conn_id
using Airflow UI
( Menu -> Admin -> Connections
). You should add a hostname / login / password information attached to it. Airflow pipelines retrieve centrally-managed connections information by specifying the relevant conn_id.
Author Dennys Regalado
LastMod 2021-02-03