Skip to main content

A lightweight module that wraps and extends the PyMSSQL library.

Project description

pymssql-utils (ALPHA)

A lightweight module that wraps and extends the pymssql library.

The aim of this module is to make it easier to use pymssql by:

  • Reducing the amount of boilerplate code needed, and being fully type hinted.
  • Baking in sensible defaults and good usage patterns.
  • Returning a helpful DatabaseResult class for each execution.
  • Parsing various SQL Types to native Python types that pymssql misses.
  • Making it easier to serialise your data.
  • Letting you easily choose how to handle errors.
  • Providing various utility functions for building dynamic SQL queries or logging query output.
  • Fixing various edge case bugs that arise when using pymssql.

The trade-off with "baking in" various patterns and options is that this module is opinionated as to what best practice is. This module does not strive to be the most performant or flexible way of using pymssql, for that just use pymssql. However, this module aims to make interfacing with a MS SQL server to be as hassle-free as possible, while making your code explicit and neat.

This module was created naturally over the course of a few years of using pymssql in various projects.

Please raise any suggestions or issues via GitHub.

Installation

This module can be installed via pip: pip install pymssql-utils.

This module requires Python >= 3.6 and Pip >= 19.3

Quick Start (TODO)

Running a simple query:

import os

import pymssqlutils as sql

os.environ["DB_NAME"] = "MASTER"

Notes

Why pymssql when Microsoft officially recommends pyodbc (opinion)?

The main difference between pyodbc and pymssql is the drivers they use. The ODBC are newer and have various levels of support on differing linux distributions, and if you develop for containers or distribute code onto different platforms you can run into ODBC driver-related issues that FreeTDS tends to not have.

There are other minor reasons someone might prefer pymssql, e.g.:

  • pymssql's parameter subsitution is done client-side improving operation visibility.
  • pymssql also has support for MSSQL specific data types such as Datetimeoffset.

Project details


Download files

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

Source Distribution

pymssql-utils-0.0.5.tar.gz (6.7 kB view hashes)

Uploaded Source

Built Distribution

pymssql_utils-0.0.5-py3-none-any.whl (16.8 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