--- id: sqlparams version: "6.2.0" license: MIT License license_treatment: permissive maintenance: dormant --- # sqlparams — Convert between various DB API 2.0 parameter styles. License: permissive · Maintenance: dormant · Downloads: 6.8M/mo ## 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 above — 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 pip install sqlparams uv add sqlparams 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_current - Install friction: low - Maintenance: dormant - Downloads: 6.8M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags SQL parameter style conversion, named to qmark parameters, DB API parameter translation, SQL query parameter normalization, database driver parameter adapter, convert SQL parameter formats, pyodbc parameter conversion, parameter-conversion, db-api-2.0 [View on SkillFed](https://skillfed.io/packages/sqlparams) · [View on PyPI](https://pypi.org/project/sqlparams/)