Development Status
- 5 - Production/Stable
Intended Audience
- Developers
Programming Language
- Python
- Python :: 3.9
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
- Python :: 3.13
- Python :: 3.14
- Python :: 3.15
- Python :: Implementation :: CPython
Topic
- Database
- Database :: Database Engines/Servers
- Software Development :: Libraries :: Python Modules
Operating System
- Microsoft :: Windows
- POSIX
- Unix
pymssql - DB-API interface to Microsoft SQL Server
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:
New development is happening on GitHub at:
There is a Google Group for discussion at:
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.4.1 - 2026-09-07 - Mikhail Terekhov
General
Fix socket resource leak on failed connections (#1002), thanks to gintsmurans.
Enable free-threaded Python 3.14 wheel builds (#1004).
Add wheels for Python 3.15 (PR #1016), thanks to edgarrmondragon.
Version 2.4.0 - 2026-08-31 - Mikhail Terekhov
General
Update license information in pyproject.toml, thanks to ecederstrand (PR #1003).
Update win-iconv to 0.0.10.
Fix datetime conversion for BCP operations and build on Windows (PR #1015).
Update to latest OpenSSL version on Windows (currently 4.0.2).
Update FreeTDS to 1.5.19 for wheels.