ИИ-инструменты и скрипты
FastAPI + PostgreSQL Functions: Safe DB Workflow
Это объявление показано на языке оригинала (английский).
Safe loop for FastAPI apps whose business logic sits in PostgreSQL functions: query the live DB with rollback, diff repo versus deployed functions, regression-test a recursive function rewrite, then deploy and audit security.
Что вы получите: 1 файл · 8.5 KB · ZIP
Варианты покупкиОписание товара
When business logic lives in PostgreSQL functions, the question "is the function in git the one that is live?" matters, and a rewritten recursive function can quietly change totals. This skill is a work loop for that architecture: thin FastAPI routers calling SELECT * FROM function(...), SQL files in the repo, Jinja templates on top.
What is inside: - SKILL.md - live database rules (always roll back, read-only by default); changing a recursive function such as a bill-of-materials or category tree, including the rule that a pure regrouping may change rows but must keep leaf totals; running the app locally only when a page check is needed; commit, push and deploy, with a prod-parity check before risky dependency or Dockerfile changes; a security audit checklist for cookie-session apps; a finish list; and an Adapt-to-your-setup section. - scripts/db.py - a query helper: q runs a query and always rolls back, fn prints the live source of a function, diff compares the live function with the file in your repo, token-normalised. Configured by DATABASE_URL or PG variables. - scripts/func_regress.py - loads a candidate function as a temporary object (no lock on the live one, nothing committed), runs old and new for every root id, and reports changed rows, changed leaf totals, slow roots and errors.
Who it is for: solo developers and small teams with a FastAPI plus PostgreSQL stack. Needs psycopg2-binary and database access. It is also part of the Production Ops: DB, Scrapers, Trading Bot pack at a lower per-skill price.
Example request
I rewrote bom_tree() to add a nested level. Check it against every real root before I apply it, and tell me if the repo version matches what is live.
Example result
Example on a fictional setup (DB: shop, function: public.bom_tree, SQL files in sql/).
- Repo versus live: db.py diff bom_tree reports the token-normalised bodies differ. The live function has an extra DISTINCT that is not in sql/bom_tree.sql, so someone patched production by hand. Decision needed from you: which version is the baseline. I used the live one as baseline.
- Regression, nothing applied: func_regress.py --file candidate.sql --func bom_tree --roots-sql "select distinct id from items" --timeout 8s loads the candidate as pg_temp.bom_tree_new, so no lock on the live function and nothing committed.
- Result over 2,140 roots: 312 roots changed rows (expected, the new nested level), 0 roots changed per-leaf totals, 3 roots slow (new more than 3x live and over 1 s), 0 errors or timeouts.
- Reading: a pure regrouping may change rows but must keep totals, and totals held. The 3 slow roots are the deepest trees; add an index on the parent column before applying and re-run just those 3.
Next: apply in a transaction after the index, re-run db.py diff to confirm repo and live match, then commit the SQL file. Nothing has been changed on the live DB.
Requirements
- Claude Code or a compatible agent runtime
- Python 3 with psycopg2-binary for the helper scripts
- Access to a PostgreSQL database (a read-only role is enough for most steps)
- Git, and a deploy path such as ssh or docker compose
How to install
Unzip into your Claude Code skills folder (~/.claude/skills/ or .claude/skills/ in a project) and start a new session; the skill loads by its description.
Что вы получите
1 файл · 8.5 KB
- fastapi-postgres-workflow.zipZIP · 8.5 KB
ИИ-инструменты и скрипты
FastAPI + PostgreSQL Functions: Safe DB Workflow
Это объявление показано на языке оригинала (английский).
Safe loop for FastAPI apps whose business logic sits in PostgreSQL functions: query the live DB with rollback, diff repo versus deployed functions, regression-test a recursive function rewrite, then deploy and audit security.
Теги
Частые вопросы
Доступ открывается сразу?
Да. Это цифровой товар - скачать его можно сразу после оплаты, прямо из своей библиотеки.
Можно ли использовать в коммерческих проектах?
Да. Коммерческое использование разрешено: в своём бизнесе и в том, что вы продаёте. Перепродавать и распространять сам файл нельзя.
Какие условия возврата?
Запросить возврат можно в течение 30 дней. Если что-то не так, оформите заявку в своём заказе - её рассмотрит команда Getly.
Какие форматы и размеры файлов я получу?
Вы скачаете 1 файл - ZIP - всего 8.5 KB.
Обновления бесплатны?
Да - когда продавец выпускает новую версию, вы можете бесплатно скачать актуальные файлы из своей библиотеки. Последние изменения смотрите в истории версий.
Цена
$6.00



