Skip to main content

DB-API interface to Microsoft SQL Server for Python. (new Cython-based version)

Project description

pymssql - DB-API interface to Microsoft SQL Server

https://github.com/pymssql/pymssql/workflows/Linux/badge.svg https://github.com/pymssql/pymssql/workflows/macOS/badge.svg https://github.com/pymssql/pymssql/workflows/Windows/badge.svg http://img.shields.io/pypi/dm/pymssql.svg http://img.shields.io/pypi/v/pymssql.svg

A simple database interface for Python that builds on top of FreeTDS to provide a Python DB-API (PEP-249) interface to Microsoft SQL Server.

Detailed information on pymssql is available on the website:

pymssql.readthedocs.io

New development is happening on GitHub at:

github.com/pymssql/pymssql

There is a Google Group for discussion at:

groups.google.com

Getting started

pymssql wheels are available from PyPi. To install it run:

pip install -U pip
pip install pymssql

Most of the times this should be all what’s needed. The official pymssql wheels bundle a static copy of FreeTDS and have SSL support so they can be used to connect to Azure.

Basic example

conn = pymssql.connect(server, user, password, "tempdb")
cursor = conn.cursor(as_dict=True)

cursor.execute('SELECT * FROM persons WHERE salesrep=%s', 'John Doe')
for row in cursor:
    print("ID=%d, Name=%s" % (row['id'], row['name']))

conn.close()

Recent Changes

Version 2.3.2 - 2024-11-20 - Mikhail Terekhov

General

  • Update FreeTDS to 1.4.23.

  • Build wheels for Python-3.13 on Windows and MacOS.

Internals

  • Fix build wheels for Python-3.13 on Windows.

  • Drop build in actions for Python 3.6, 3.7 and 3.8.

  • Add build in actions for Python-3.13.

  • Workaround setuptools-74.0 changes.

Version 2.3.1 - 2024-08-25 - Mikhail Terekhov

General

  • Fix SP returning NULL (closes #441).

  • Update FreeTDS to 1.4.22 (closes #895).

  • Require Cython>3.0.10.

  • Add python 3.13 Linux wheels (closes #900).

  • Drop manylinux2010 wheels.

  • Drop 3.7 and 3.8 wheels on MacOS.

  • Drop 3.6 wheels on Linux.

Supported by

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