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 details)

Uploaded Python 3

File details

Details for the file airflow_sqlcmd_operator-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for airflow_sqlcmd_operator-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2ac011631535cbf3e39d3a0f132687e9e30fd7eef36aae5d332541816c442f5b
MD5 9927b95b2860f4602dc8841f48be5c80
BLAKE2b-256 b3a5a4e31051bde7d22973a1ab740d23a81fa2d8b4f51440a01a7c35432f86c7

See more details on using hashes here.

Provenance

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