返回顶部
s

sql-formatterSQL格式化工具

Format, minify, and lint SQL queries from the command line. Formats SQL with proper indentation and keyword casing, minifies by removing whitespace and comments, and lints for common anti-patterns (SELECT *, inconsistent casing, missing semicolons, trailing whitespace). No external dependencies — pure Python. Use when formatting SQL queries, cleaning up SQL files, minifying SQL for production, or checking SQL quality.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
150
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

sql-formatter

SQL 格式化工具

零依赖地格式化、压缩和检查SQL代码。

命令

所有命令均使用 scripts/sql_format.py。

格式化SQL

bash
python3 scripts/sql_format.py format --sql SELECT id, name FROM users WHERE active = true
python3 scripts/sql_format.py format --input query.sql
python3 scripts/sql_format.py format --input query.sql --output formatted.sql
python3 scripts/sql_format.py format --input query.sql --indent 4 --lowercase
echo SELECT * FROM t | python3 scripts/sql_format.py format --input -

默认在主要子句(SELECT、FROM、WHERE、JOIN、ORDER BY等)前添加换行,缩进AND/OR/ON,并将关键字转换为大写。

压缩SQL

bash
python3 scripts/sql_format.py minify --sql SELECT id, name FROM users -- comment
python3 scripts/sql_format.py minify --input query.sql

去除注释,压缩空白,移除括号和逗号周围不必要的空格。

检查SQL

bash
python3 scripts/sql_format.py lint --input query.sql
python3 scripts/sql_format.py lint --sql SELECT * FROM users WHERE 1=1 --json

检查以下内容:SELECT *、多余空格、制表符、!= 与 <>、双逗号、WHERE 1=1、长行(超过120字符)、尾部空白、缺少分号、关键字大小写不一致。

支持的SQL

支持SELECT、INSERT、UPDATE、DELETE、CREATE、ALTER、DROP、WITH(CTE)、JOIN(所有类型)、子查询、字符串字面量、双引号标识符、单行和多行注释。

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 sql-formatter-1776104400 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 sql-formatter-1776104400 技能

通过命令行安装

skillhub install sql-formatter-1776104400

下载

⬇ 下载 sql-formatter v1.0.0(免费)

文件大小: 5.67 KB | 发布时间: 2026-4-17 16:13

v1.0.0 最新 2026-4-17 16:13
Initial release of SQL Formatter:

- Format, minify, and lint SQL queries directly from the command line.
- Provides formatting with indentation and configurable keyword casing.
- Minifies SQL by removing comments and collapsing whitespace.
- Lints for common SQL anti-patterns (e.g., SELECT *, missing semicolons, long lines).
- No external dependencies; implemented in pure Python.
- Supports major SQL statement types, including SELECT, INSERT, UPDATE, DELETE, CTEs, and various JOINs.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部