Build a Nightly SQL Review Bot with Free Models and a Free Server
说明与用途
使用免费模型和本地服务器的夜间 SQL 审核机器人,自动扫描合并的查询,识别生产风险并发布报告。
问题
A costly JOIN without an index stalled the checkout pipeline for six minutes and was missed in code review.
结果
The bot runs nightly, identifies missing filters, limits, and inefficient joins, and outputs a concise report, reducing manual review effort.
工作流
- Deploy a free local server (Docker or Kubernetes) exposing an OpenAI-compatible API.
- Configure the client to use the free model via the local endpoint.
- Write a script that extracts SQL statements from commits made since midnight and sends each to the local model for review.
- Schedule the script to run nightly (cron or GitHub Actions).
- Evaluate the bot against a labeled dataset and adjust expectations with a decision table.
证据
Pre-commit hooks interrupt developers. They create friction, prompt rework, and get disabled after the third false positive.
A nightly bot runs after everyone goes home. It scans the queries merged during the day, flags risky patterns, and posts a report to a channel or file.
- 记录日期: 2026-09-05T18:22:33.254Z