Skip to content

Quantco/pytsql

Folders and files

NameName
Last commit message
Last commit date
Apr 3, 2023
Apr 3, 2023
Apr 3, 2023
Apr 3, 2023
Apr 12, 2022
Feb 21, 2022
Aug 2, 2022
Mar 27, 2022
Apr 14, 2022
Jan 26, 2022
Apr 3, 2023
Apr 3, 2023
Apr 3, 2023
Jan 30, 2023
Apr 11, 2022

Repository files navigation

pytsql

CI Documentation Status Conda-forge PypiVersion

pytsql allows to run mssql scripts, typically run from GUIs, from Python.

This, in turn, eases concurrent, scheduled and chained execution of scripts in a workflow. Put differently, it enables automated execution of Microsoft sql server scripts.

Moreover, pytsql supports parametrization of scripts, akin to templating.

Please have a look at our documentation if you're curious about more details.

Installation

To install, execute:

pip install pytsql

or in a conda environment

mamba install pytsql

Be aware that depending on your platform, you'will need specific drivers (Windows, Linux, macOS).

Usage

pytsql is tailored to run with MSSQL. Other sql dialects are not supported.

The main function of interest is execute. It requires a sqlalchemy Engine object as well as the path to the sql script of interest. A typical use case might look as follows:

import pytsql
from sqlalchemy import sa

db_connection_string = "connection_to_my_database"
engine = sa.get_engine(db_connection_string)

pytsql.execute("my_sql_script.sql", engine)

Please also have a look at our documentation sections on usage and development.

Credits

Grammar is based on antlr4/grammars-v4.