D6u.putty PDocsProgramming
Related
Go 1.26's Source-Level Inliner: A Q&A Guide to API Migration and RefactoringHow to Build a Conversational Interface for Spotify Ads with Claude Code PluginsFrom Pixels to Purpose: How Mutual Information Transforms Imaging System Design7 Steps to Modernize Your Go Code with the New go fix CommandImaging Systems Can Now Be Optimized for Information Content, Not Just Resolution, Says New NeurIPS StudyMastering Structured Prompt-Driven Development: A Practical Guide for Teams7 Essential Insights into Structured-Prompt-Driven DevelopmentMcDonald's Executive Lifts Lid on Chaotic Response to Viral 'Grimace Shake' Death Trend

Breaking: mssql-python Now Supports Both Parameter Styles – Python Devs Can Finally End the SQL Placeholder Debate

Last updated: 2026-05-10 07:26:53 · Programming

Breaking: mssql-python Adds Dual Parameter Style Support

In a move that resolves a long-standing developer debate, the mssql-python driver now supports both positional (qmark) and named (pyformat) parameter styles simultaneously. This dual support, announced today, allows Python developers to write SQL queries using either ? placeholders or %(name)s placeholders, ending the need to choose between conciseness and clarity.

Breaking: mssql-python Now Supports Both Parameter Styles – Python Devs Can Finally End the SQL Placeholder Debate
Source: devblogs.microsoft.com

"We've added dual parameter style support to mssql-python, enabling both qmark and pyformat parameter styles in Python applications that interact with SQL Server and Azure SQL," said Sumit Sarabhai, a reviewer of the feature. "This is especially useful if you're building complex queries, dynamically assembling filters, or migrating existing code that already uses named parameters with other DBAPI drivers."

Background

The Python DB-API 2.0 specification (PEP 249) defines several ways to pass parameters to SQL queries. The two most popular are positional placeholders (?) and named placeholders (%(name)s). While positional style is concise, it becomes error-prone as the number of parameters grows. Named parameters offer self-documenting queries and reuse.

Previously, mssql-python only supported the qmark style. This worked for simple queries, but tracking parameter order became a source of subtle bugs.

What This Means

For developers, this dual support means greater flexibility and fewer errors. Queries are easier to read and maintain. Migrating code from other DBAPI drivers that rely on named parameters becomes straightforward.

"Mix up the order and it’s easy to introduce subtle, hard-to-spot bugs," Sarabhai added. "Named parameters eliminate that risk."

Breaking: mssql-python Now Supports Both Parameter Styles – Python Devs Can Finally End the SQL Placeholder Debate
Source: devblogs.microsoft.com

Parameter reuse is another key advantage. Developers can use the same named value multiple times in a query without repeating the value, reducing redundancy and improving code clarity.

Example: Positional vs. Named

# Positional (qmark) - which ? is which?
cursor.execute("UPDATE users SET name=?, email=?, age=? WHERE id=? AND status=?", 
               (name, email, age, user_id, status))

# Named (pyformat) - self-documenting
cursor.execute("UPDATE users SET name=%(name)s, email=%(email)s, age=%(age)s WHERE id=%(id)s AND status=%(status)s",
               {"name": name, "email": email, "age": age, "id": user_id, "status": status})

How to Try It

The updated driver is available now via pip install mssql-python. The team invites the Python developer community to test the dual parameter style support and provide feedback.

"Calling all Python + SQL developers! We invite the community to try out mssql-python and help us shape the future of high-performance SQL Server connectivity in Python," the announcement concluded.

Industry Reaction

Early adopters have praised the move. "This eliminates a major pain point when working with complex queries in Python," said one developer.

For more details, visit the official documentation.