Show HN: Py-SQL-cleaner – format SQL embedded in Python strings
Solves the problem that existing Python formatters ignore embedded SQL and SQL formatters don't target SQL within Python files. Positions itself as a specialized tool for 'SQL cleanup problem' in Python codebases.
View Origin Link
Product Positioning & Context
AI Executive Synthesis
Solves the problem that existing Python formatters ignore embedded SQL and SQL formatters don't target SQL within Python files. Positions itself as a specialized tool for 'SQL cleanup problem' in Python codebases.
Py-SQL-cleaner addresses a specific, yet common, developer pain point: the lack of proper formatting for SQL embedded within Python codebases. This tool fills a gap left by both Python and SQL formatters, improving code readability and maintainability in projects where SQL queries are frequently constructed programmatically. By intelligently detecting and formatting embedded SQL while avoiding dynamic or templated sections, it streamlines development workflows and reduces cognitive load for engineers. This niche utility highlights the ongoing demand for specialized developer tools that enhance code quality and consistency, particularly in environments integrating multiple languages or data access patterns. Such tools contribute to overall engineering efficiency and reduce technical debt.
Hi HN, I built py-sql-cleaner, a CLI for formatting SQL embedded in Python files.Python formatters handle Python syntax. They do not format SQL written inside Python code.
On the other hand, SQL formatters usually target SQL files or raw SQL text, not SQL embedded inside a Python file.Still, I think it is not uncommon to find long SQL queries inside Python codebases.py-sql-cleaner detects embedded SQL inside Python files and works only on that SQL.
The main things it can do are: find the SQL, format it in place, or extract it into a .sql file.It avoids rewriting SQL that depends on runtime values or template expansion.
For example, SQL containing parameters like %s or :name, or Jinja-style template variables like {{ ds }}, is skipped by default.Try it with: uvx py-sql-cleaner list path/to/file.py
uvx py-sql-cleaner format path/to/file.py --dry-run
If you write Python, have run into this kind of SQL cleanup problem, or are just curious, I’d be happy if you take a look.
CLI
formatting SQL
embedded SQL
Python strings
Python files
Python formatters
SQL formatters
raw SQL text
Related Ecosystem & Alternatives
Discover adjacent products, open-source repositories, and developer tools sharing similar technical architecture.
Deep-Dive FAQs
What is Py-SQL-cleaner – format SQL embedded in Python strings?
Py-SQL-cleaner – format SQL embedded in Python strings is analyzed by our AI as: Solves the problem that existing Python formatters ignore embedded SQL and SQL formatters don't target SQL within Python files. Positions itself as a specialized tool for 'SQL cleanup problem' in Python codebases.. It focuses on Py-SQL-cleaner addresses a specific, yet common, developer pain point: the lack of proper formatting for SQL embedded within Python codebases. This...
Where did Py-SQL-cleaner – format SQL embedded in Python strings originate?
Data for Py-SQL-cleaner – format SQL embedded in Python strings was aggregated directly from the Hacker News community ecosystem, representing raw developer and early-adopter sentiment.
When was Py-SQL-cleaner – format SQL embedded in Python strings publicly launched?
The initial public indexing or launch date for Py-SQL-cleaner – format SQL embedded in Python strings within our tracked developer communities was recorded on May 29, 2026.
How popular is Py-SQL-cleaner – format SQL embedded in Python strings?
Py-SQL-cleaner – format SQL embedded in Python strings has achieved measurable traction, logging over 5 traction score and facilitating 0 recorded discussions or engagements.
Which technical categories define Py-SQL-cleaner – format SQL embedded in Python strings?
Based on metadata extraction, Py-SQL-cleaner – format SQL embedded in Python strings is categorized under topics such as: CLI, formatting SQL, embedded SQL, Python strings.
What are some commercial alternatives to Py-SQL-cleaner – format SQL embedded in Python strings?
Our semantic intelligence engine identifies potential commercial alternatives in the SaaS space, such as Freesolo Flash, which offers overlapping value propositions.
How does the creator describe Py-SQL-cleaner – format SQL embedded in Python strings?
The original author or development team describes the product as follows: "Hi HN, I built py-sql-cleaner, a CLI for formatting SQL embedded in Python files.Python formatters handle Python syntax. They do not format SQL written inside Python code.
On the other hand, SQL f..."
Community Voice & Feedback
No active discussions extracted yet.
Discovery Source

Hacker News
Aggregated via automated community intelligence tracking.
Tech Stack Dependencies
No direct open-source NPM package mentions detected in the product documentation.
Media Tractions & Mentions
No mainstream media stories specifically mentioning this product name have been intercepted yet.
Deep Research & Science
No direct peer-reviewed scientific literature matched with this product's architecture.