Py-SQL-cleaner – format SQL embedded in Python strings
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…
What it does
In the maker’s words, at launch
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.
Does the same job
all alternatives →- ISInline SQL in any Python program2022 · github.com · ▲26

- SSSPyQL – SQL with Python in the middle2022 · github.com · ▲105
SPyQL (https://github.com/dcmoura/spyql) is SQL with Python in the middle, an open-source project fully written in Python for making command-line data processing more intuitive, readable and powerful. Try mixing in the same pot: a SQL SELECT for providing the structure, Python expressions for defining transformations and conditions, the essence of awk as a data-processing language, and the JSON handling capabilities of jq. How does a SPyQL query looks like? $ spyql “ IMPORT pendulum AS p SELECT (p.now() - p.from_timestamp(purchase_ts)).in_days() AS days_ago, sum_agg(price…


- CPCsql – Python lib for composeable SQL queries2020 · github.com · ▲89
More dev tools this month
the category →



Open-source GTM skills for technical founders
Dev tools · 29d ago · gtmcofounder.com


OpenTrailPaper is open-source bike computer firmware for the LilyGO T5S3 4.7" E-Paper PRO. It supports offline maps, GPX routes, FIT recording and Bluetooth sensors.
Dev tools · 1d ago · opentrailpaper.com
Launched alongside, May 2026
the whole month →

Parallel agents, diff reviewer, and multi-model comparisons
Dev tools · May 2026 · kilo.ai


- NW
Hey HN, Henry here from Cactus. We open-sourced Needle, a 26M parameter function-calling (tool use) model. It runs at 6000 tok/s prefill and 1200 tok/s decode on consumer devices. We were always frustrated by the little effort made towards building agentic models that run on budget phones, so we conducted investigations that led to an observation: agentic experiences are built upon tool calling, and massive models are overkill for it. Tool calling is fundamentally retrieval-and-assembly (match query to tool name, extract argument values, emit JSON), not reasoning. Cross-attention…
Life & fun · May 2026 · github.com
- FM
Dev tools · May 2026 · github.com