skillfed

sqlparams

Convert between various DB API 2.0 parameter styles.

sqlparams v6.2.0 6.8M downloads/30d#1,851 on PyPI41
Permissive license MIT License DORMANT released

What it is and what it does

sqlparams is a utility for translating SQL parameter styles between formats. Many Python database drivers (like pyodbc) support only one parameter style—typically ordinal qmark (?) or format (%)—but developers often prefer named parameters (:name) for readability and safety. This package bridges that gap by accepting a query and parameters in any style and converting them to the style your driver expects.

You create an SQLParams instance specifying the input and output styles, then call format() or formatmany() to convert queries and their parameter dictionaries. It handles scalar values, tuples (for SQL IN clauses), and batch operations. The package supports seven parameter styles: qmark, numeric, named, format, pyformat, numeric_dollar, and named_dollar, plus Oracle and SQL Server variants.

Use it for:

  • Use it to write portable database code that works with drivers supporting only qmark or format styles while using named parameters in your application.
  • Use it to safely expand tuples into SQL IN clauses without manual string concatenation or SQL injection risk.
  • Use it to convert batch operations (executemany) by formatting multiple parameter sets at once with formatmany().
  • Use it to migrate code between database systems that prefer different parameter conventions (e.g., Oracle to SQL Server).
  • Use it to strip SQL comments before parameter expansion to avoid accidentally matching variable-like strings in comments.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Converts SQL queries between different parameter styles (named, ordinal, numeric, and dollar-sign variants) to match what your database driver supports.

Yes. sqlparams solves a real compatibility problem with minimal friction: it's a pure-Python package with no dependencies, supports current Python versions (3.8–3.13), carries no known vulnerabilities, and uses a permissive MIT license. Its dormant maintenance status is not a concern for a stable utility with a narrow, well-defined scope. Install it if you need to bridge parameter style mismatches between your code and your database driver.

Install

sqlparams on PyPI

pip

pip install sqlparams

uv

uv add sqlparams

poetry

poetry add sqlparams

Installing sqlparams

Before you install

Low friction: pure Python wheel with no runtime dependencies. Maintenance is dormant (566 days since last release) but the repository remains active with a recent commit on 2025-01-25, and the package has been stable since its 2012 initial release.

License in practice

MIT License (permissive): you can use, modify, and distribute sqlparams freely in commercial and private projects with minimal restrictions.

Quickstart

import sqlparams

query = sqlparams.SQLParams('named', 'qmark')
sql, params = query.format('SELECT * FROM users WHERE name = :name;', {'name': 'Thorin'})
print(sql)      # SELECT * FROM users WHERE name = ?;
print(params)   # ['Thorin']

Verify before relying

  • Whether the package handles all edge cases in parameter expansion (e.g., nested tuples, special characters in identifiers) as robustly as production use requires.
  • Performance characteristics when converting large or complex queries with many parameters.

Package facts

License MIT License (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance dormant — 566 days since the last release
Last repo commit
First released
Downloads 6,777,211/month — #1,851 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: sqlparams-6.2.0-py3-none-any.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: DatabaseTopic :: Software Development :: Libraries :: Python ModulesTopic :: Utilities

Tags

SQL parameter style conversionnamed to qmark parametersDB API parameter translationSQL query parameter normalizationdatabase driver parameter adapterconvert SQL parameter formatspyodbc parameter conversion
parameter-conversiondb-api-2.0

More Python Modules packages