types-pymssql

raw JSON →
2.1.0 verified Fri May 01 auth: no python

Typing stubs for pymssql. Version 2.1.0 is a stub package for type checkers (mypy, pyright, etc.) to enable type hints for pymssql. Maintained by the typeshed project. Releases follow pymssql versioning.

pip install types-pymssql
error Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'pymssql'
cause pymssql runtime library not installed.
fix
pip install pymssql
error error: Cannot find implementation or library stub for module named 'pymssql' [import]
cause types-pymssql not installed for type checker.
fix
pip install types-pymssql
gotcha types-pymssql provides type hints only. It does not replace the pymssql runtime package. You must install pymssql separately.
fix pip install pymssql
gotcha The stubs may lag behind pymssql releases. If pymssql adds new features, types-pymssql might not have type hints for them yet.
fix Use `type: ignore` for new methods or contribute to typeshed.

Basic connection test using environment variables for credentials.

import pymssql
import os

conn = pymssql.connect(
    server=os.environ.get('PYMSSQL_SERVER', ''),
    user=os.environ.get('PYMSSQL_USER', ''),
    password=os.environ.get('PYMSSQL_PASSWORD', ''),
    database=os.environ.get('PYMSSQL_DB', '')
)
cursor = conn.cursor()
cursor.execute('SELECT 1')
row = cursor.fetchone()
print(row)
cursor.close()
conn.close()