Skip to main content

Custom Airflow BashOperator for Microsoft sqlcmd

Project description

airflow-sqlcmd-operator

Custom Airflow BashOperator for the Microsoft sqlcmd.

This package utilizes the sqlcmd to run Microsoft SQLServer scripts on Linux like you would use them on SSMS for example.

The sqlcmd supports SQLServer scripts with commands like GO, USE [db_name], etc, and multiple statements.

Requirements

You must have sqlcmd already installed and (currently) on following location: "/opt/mssql-tools/bin/sqlcmd".

Installing on Ubuntu with apt:

curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list

# install required packages for pyodbc
apt-get update
ACCEPT_EULA=Y apt-get install -y msodbcsql17 unixodbc-dev mssql-tools && apt-get clean

Usage

On a dag, you can call it like this:

from airflow_sqlcmd_operator import SqlcmdOperator

sqlcmd = SqlcmdOperator("MyDB", "/scripts/folder/mydag", "do_stuff.sql", dag=dag)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

airflow_sqlcmd_operator-0.5.1-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page