---
title: "Write SQL Your Way: Dual Parameter Style Benefits in mssql-python"
description: "mssql-python, Microsoft's Python driver for SQL Server and Azure SQL, now accepts both DB-API qmark (?) and pyformat (%(name)s) parameter styles, choosing between them by whether a tuple/list or a dict is passed."
url: "https://swe.quest/articles/write-sql-your-way-dual-parameter-style-benefits-in-mssql-python-5967e83bc5a08c68"
canonical: "https://devblogs.microsoft.com/python/write-sql-your-way-dual-parameter-style-benefits-in-mssql-python/"
source: "Microsoft for Python Developers"
published: "2026-04-07"
difficulty: "medium"
kind: "Announcement"
reading_minutes: 7
tags: ["python","sql","databases","api-design"]
---

# Write SQL Your Way: Dual Parameter Style Benefits in mssql-python

A post on [Microsoft for Python Developers](https://swe.quest/sources/ms-python.md), published 2026-04-07, 7 min read, Announcement. Original: [https://devblogs.microsoft.com/python/write-sql-your-way-dual-parameter-style-benefits-in-mssql-python/](https://devblogs.microsoft.com/python/write-sql-your-way-dual-parameter-style-benefits-in-mssql-python/)

## Summary

mssql-python, Microsoft's Python driver for SQL Server and Azure SQL, now accepts both DB-API qmark (?) and pyformat (%(name)s) parameter styles, choosing between them by whether a tuple/list or a dict is passed. For dicts, the driver scans the SQL for named placeholders (skipping string literals, comments and bracketed identifiers), validates keys, builds a positional tuple that duplicates reused values, and rewrites the query to ? before ODBC binding, so there is no change in database communication or SQL-injection safety. Named parameters help with self-documenting queries, value reuse, dynamic filter building and sharing one dict across queries. Extra dict keys are ignored, mixing styles in one query fails, %% escapes literal patterns, and module paramstyle reports "pyformat".

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Python](https://swe.quest/tags/python.md) (Languages)
- [SQL](https://swe.quest/tags/sql.md) (Languages)
- [Databases](https://swe.quest/tags/databases.md) (Data & databases)
- [API design](https://swe.quest/tags/api-design.md) (Backend & APIs)

## Prerequisites

- Python DB-API basics ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- parameterized SQL queries ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))

## Keywords

mssql-python, SQL Server, Azure SQL, PEP 249, DB-API 2.0, ODBC

## Related posts

- [Even Friendlier SQL with DuckDB](https://swe.quest/articles/even-friendlier-sql-with-duckdb-26e7b4e6715ab305.md): DuckDB · 2023-08-23 · Medium · 16 min read · SQL, Analytics & OLAP, Databases
  DuckDB extends SQL syntax with features that simplify everyday queries and enable dynamic analysis.
- [Gems of DuckDB 2.0.0](https://swe.quest/articles/gems-of-duckdb-2-0-0-0cf205137ec12582.md): DuckDB · 2026-10-26 · Medium · 8 min read · Databases, SQL, Analytics & OLAP, Python
  DuckDB 2.0.0 LTS includes a set of smaller features beyond its headline items.
- [Introducing Apache Arrow Support in mssql-python](https://swe.quest/articles/introducing-apache-arrow-support-in-mssql-python-e10136b97e324bc3.md): Microsoft for Python Developers · 2026-05-04 · Medium · 6 min read · Python, Analytics & OLAP, Performance engineering, Databases
  mssql-python can now fetch SQL Server result sets directly into Apache Arrow buffers, filled by a C++ fetch loop, so no Python object is created per row.
- [Ducks in a Column](https://swe.quest/articles/ducks-in-a-column-ce42623eb848a791.md): DuckDB · 2026-11-10 · Medium · 12 min read · SQL, Analytics & OLAP, Query engines
  DuckDB stores data by column and processes it in vectors of 2,048 values, which drives its compression, projection pushdown and aggregation speed.
- [Why SQL template tags are not vulnerable to SQL injection attacks](https://swe.quest/articles/why-sql-template-tags-are-not-vulnerable-to-sql-injection-attacks-09e86639b19ec938.md): Neon · 2023-05-09 · Medium · 6 min read · Application security, JavaScript, PostgreSQL, SQL
  SQL template tags like Neon's \`sql\` function look like string interpolation but are safe from SQL injection because they are JavaScript tagged template functions.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
