Skip to content
stacks

PostgreSQL with SQLAlchemy for Python

PostgreSQL for the FastAPI stacks (python-react, python-api): Docker Compose dev and test services with healthchecks, SQLAlchemy async models with Alembic migrations, make db-* targets, and a test harness that gives each test file its own database cloned from a migrated template.

Category: service

In your existing repository

Ask your agent to check compatibility, follow this fragment’s brief, and verify the resulting project. What happens next

Applies to:
python-react, python-api
Requires tools:
docker

Add to your project

Paste the prompt into the coding agent working on your project.

View prompt
Add the postgres fragment to this existing repository. 1. Run npx @steamfield/stacks show postgres --json and check that it fits the project. If it does not, explain why before changing files. 2. Run npx @steamfield/stacks add postgres and follow the brief it prints. 3. In this repository, run npx @steamfield/stacks verify. Fix failures without weakening or skipping verification steps. 4. Summarize what changed and the verification result. Quote published stats only when they are available, including their interval and sample size. The stacks docs, written for agents, are at https://stacks.steamfield.io/llms.txt.
Or use the terminal
npx @steamfield/stacks add postgres
Verify steps
StepPhaseLayerCommand
db-upsetupinstallmake db-up
db-migratesetupinstallmake db-migrate
db-downteardowninstallmake db-down
Use with a new stack

Starting fresh instead? These stacks support this fragment.

  • python-apioptional
    npx @steamfield/stacks new python-api --with postgres
  • python-reactoptional
    npx @steamfield/stacks new python-react --with postgres

Files

  • docs/guidance/postgres/index.md

Usage

Among stacks projects in the 28 days through 30 Oct 2026: 735 projects; 87% reached a green verify (83–89%, n=455).

Weekly projects by stack

Projects whose final fragment set included this fragment, grouped by stack.

Weekly projects including this fragment, by stack: time span
Sep 1Oct 10100200300python-react · 9 Aug 2026: 240python-react · 16 Aug 2026: 230python-react · 23 Aug 2026: 240python-react · 30 Aug 2026: 250python-react · 6 Sept 2026: 270python-react · 13 Sept 2026: 290python-react · 20 Sept 2026: 295python-react · 27 Sept 2026: 325python-react · 4 Oct 2026: 345python-react · 11 Oct 2026: 255python-react · 18 Oct 2026: 235python-react · 25 Oct 2026: 155
Sep 1Oct 10100200300python-react · 9 Aug 2026: 240python-react · 16 Aug 2026: 230python-react · 23 Aug 2026: 240python-react · 30 Aug 2026: 250python-react · 6 Sept 2026: 270python-react · 13 Sept 2026: 290python-react · 20 Sept 2026: 295python-react · 27 Sept 2026: 325python-react · 4 Oct 2026: 345python-react · 11 Oct 2026: 255python-react · 18 Oct 2026: 235python-react · 25 Oct 2026: 155
Sep 1Oct 10100200300python-react · 9 Aug 2026: 240python-react · 16 Aug 2026: 230python-react · 23 Aug 2026: 240python-react · 30 Aug 2026: 250python-react · 6 Sept 2026: 270python-react · 13 Sept 2026: 290python-react · 20 Sept 2026: 295python-react · 27 Sept 2026: 325python-react · 4 Oct 2026: 345python-react · 11 Oct 2026: 255python-react · 18 Oct 2026: 235python-react · 25 Oct 2026: 155
Sep 1Oct 10100200300python-react · 9 Aug 2026: 240python-react · 16 Aug 2026: 230python-react · 23 Aug 2026: 240python-react · 30 Aug 2026: 250python-react · 6 Sept 2026: 270python-react · 13 Sept 2026: 290python-react · 20 Sept 2026: 295python-react · 27 Sept 2026: 325python-react · 4 Oct 2026: 345python-react · 11 Oct 2026: 255python-react · 18 Oct 2026: 235python-react · 25 Oct 2026: 155
Sep 1Oct 10100200300python-react · 9 Aug 2026: 240python-react · 16 Aug 2026: 230python-react · 23 Aug 2026: 240python-react · 30 Aug 2026: 250python-react · 6 Sept 2026: 270python-react · 13 Sept 2026: 290python-react · 20 Sept 2026: 295python-react · 27 Sept 2026: 325python-react · 4 Oct 2026: 345python-react · 11 Oct 2026: 255python-react · 18 Oct 2026: 235python-react · 25 Oct 2026: 155
Sep 1Oct 10100200300python-react · 9 Aug 2026: 240python-react · 16 Aug 2026: 230python-react · 23 Aug 2026: 240python-react · 30 Aug 2026: 250python-react · 6 Sept 2026: 270python-react · 13 Sept 2026: 290python-react · 20 Sept 2026: 295python-react · 27 Sept 2026: 325python-react · 4 Oct 2026: 345python-react · 11 Oct 2026: 255python-react · 18 Oct 2026: 235python-react · 25 Oct 2026: 155
Sep 1Oct 10100200300python-react · 9 Aug 2026: 240python-react · 16 Aug 2026: 230python-react · 23 Aug 2026: 240python-react · 30 Aug 2026: 250python-react · 6 Sept 2026: 270python-react · 13 Sept 2026: 290python-react · 20 Sept 2026: 295python-react · 27 Sept 2026: 325python-react · 4 Oct 2026: 345python-react · 11 Oct 2026: 255python-react · 18 Oct 2026: 235python-react · 25 Oct 2026: 155
Sep 1Oct 10100200300python-react · 9 Aug 2026: 240python-react · 16 Aug 2026: 230python-react · 23 Aug 2026: 240python-react · 30 Aug 2026: 250python-react · 6 Sept 2026: 270python-react · 13 Sept 2026: 290python-react · 20 Sept 2026: 295python-react · 27 Sept 2026: 325python-react · 4 Oct 2026: 345python-react · 11 Oct 2026: 255python-react · 18 Oct 2026: 235python-react · 25 Oct 2026: 155
  • python-api
  • python-react
Aug 1Sep 1Oct 10100200300python-react · 5 Jul 2026: 60python-react · 12 Jul 2026: 115python-react · 19 Jul 2026: 155python-react · 26 Jul 2026: 230python-react · 2 Aug 2026: 190python-react · 9 Aug 2026: 240python-react · 16 Aug 2026: 230python-react · 23 Aug 2026: 240python-react · 30 Aug 2026: 250python-react · 6 Sept 2026: 270python-react · 13 Sept 2026: 290python-react · 20 Sept 2026: 295python-react · 27 Sept 2026: 325python-react · 4 Oct 2026: 345python-react · 11 Oct 2026: 255python-react · 18 Oct 2026: 235python-react · 25 Oct 2026: 155
Aug 1Sep 1Oct 10100200300python-react · 5 Jul 2026: 60python-react · 12 Jul 2026: 115python-react · 19 Jul 2026: 155python-react · 26 Jul 2026: 230python-react · 2 Aug 2026: 190python-react · 9 Aug 2026: 240python-react · 16 Aug 2026: 230python-react · 23 Aug 2026: 240python-react · 30 Aug 2026: 250python-react · 6 Sept 2026: 270python-react · 13 Sept 2026: 290python-react · 20 Sept 2026: 295python-react · 27 Sept 2026: 325python-react · 4 Oct 2026: 345python-react · 11 Oct 2026: 255python-react · 18 Oct 2026: 235python-react · 25 Oct 2026: 155
Aug 1Sep 1Oct 10100200300python-react · 5 Jul 2026: 60python-react · 12 Jul 2026: 115python-react · 19 Jul 2026: 155python-react · 26 Jul 2026: 230python-react · 2 Aug 2026: 190python-react · 9 Aug 2026: 240python-react · 16 Aug 2026: 230python-react · 23 Aug 2026: 240python-react · 30 Aug 2026: 250python-react · 6 Sept 2026: 270python-react · 13 Sept 2026: 290python-react · 20 Sept 2026: 295python-react · 27 Sept 2026: 325python-react · 4 Oct 2026: 345python-react · 11 Oct 2026: 255python-react · 18 Oct 2026: 235python-react · 25 Oct 2026: 155
Aug 1Sep 1Oct 10100200300python-react · 5 Jul 2026: 60python-react · 12 Jul 2026: 115python-react · 19 Jul 2026: 155python-react · 26 Jul 2026: 230python-react · 2 Aug 2026: 190python-react · 9 Aug 2026: 240python-react · 16 Aug 2026: 230python-react · 23 Aug 2026: 240python-react · 30 Aug 2026: 250python-react · 6 Sept 2026: 270python-react · 13 Sept 2026: 290python-react · 20 Sept 2026: 295python-react · 27 Sept 2026: 325python-react · 4 Oct 2026: 345python-react · 11 Oct 2026: 255python-react · 18 Oct 2026: 235python-react · 25 Oct 2026: 155
Aug 1Sep 1Oct 10100200300python-react · 5 Jul 2026: 60python-react · 12 Jul 2026: 115python-react · 19 Jul 2026: 155python-react · 26 Jul 2026: 230python-react · 2 Aug 2026: 190python-react · 9 Aug 2026: 240python-react · 16 Aug 2026: 230python-react · 23 Aug 2026: 240python-react · 30 Aug 2026: 250python-react · 6 Sept 2026: 270python-react · 13 Sept 2026: 290python-react · 20 Sept 2026: 295python-react · 27 Sept 2026: 325python-react · 4 Oct 2026: 345python-react · 11 Oct 2026: 255python-react · 18 Oct 2026: 235python-react · 25 Oct 2026: 155
Aug 1Sep 1Oct 10100200300python-react · 5 Jul 2026: 60python-react · 12 Jul 2026: 115python-react · 19 Jul 2026: 155python-react · 26 Jul 2026: 230python-react · 2 Aug 2026: 190python-react · 9 Aug 2026: 240python-react · 16 Aug 2026: 230python-react · 23 Aug 2026: 240python-react · 30 Aug 2026: 250python-react · 6 Sept 2026: 270python-react · 13 Sept 2026: 290python-react · 20 Sept 2026: 295python-react · 27 Sept 2026: 325python-react · 4 Oct 2026: 345python-react · 11 Oct 2026: 255python-react · 18 Oct 2026: 235python-react · 25 Oct 2026: 155
Aug 1Sep 1Oct 10100200300python-react · 5 Jul 2026: 60python-react · 12 Jul 2026: 115python-react · 19 Jul 2026: 155python-react · 26 Jul 2026: 230python-react · 2 Aug 2026: 190python-react · 9 Aug 2026: 240python-react · 16 Aug 2026: 230python-react · 23 Aug 2026: 240python-react · 30 Aug 2026: 250python-react · 6 Sept 2026: 270python-react · 13 Sept 2026: 290python-react · 20 Sept 2026: 295python-react · 27 Sept 2026: 325python-react · 4 Oct 2026: 345python-react · 11 Oct 2026: 255python-react · 18 Oct 2026: 235python-react · 25 Oct 2026: 155
Aug 1Sep 1Oct 10100200300python-react · 5 Jul 2026: 60python-react · 12 Jul 2026: 115python-react · 19 Jul 2026: 155python-react · 26 Jul 2026: 230python-react · 2 Aug 2026: 190python-react · 9 Aug 2026: 240python-react · 16 Aug 2026: 230python-react · 23 Aug 2026: 240python-react · 30 Aug 2026: 250python-react · 6 Sept 2026: 270python-react · 13 Sept 2026: 290python-react · 20 Sept 2026: 295python-react · 27 Sept 2026: 325python-react · 4 Oct 2026: 345python-react · 11 Oct 2026: 255python-react · 18 Oct 2026: 235python-react · 25 Oct 2026: 155
  • python-api
  • python-react

Stacks projects per UTC week through 30 Oct 2026. Published stack counts only.

Data table
Week endingStackProjects
5 Jul 2026python-api–
12 Jul 2026python-api–
19 Jul 2026python-api–
26 Jul 2026python-api–
2 Aug 2026python-api–
9 Aug 2026python-api–
16 Aug 2026python-api–
23 Aug 2026python-api–
30 Aug 2026python-api–
6 Sept 2026python-api–
13 Sept 2026python-api–
20 Sept 2026python-api–
27 Sept 2026python-api–
4 Oct 2026python-api–
11 Oct 2026python-api–
18 Oct 2026python-api–
25 Oct 2026python-api–
5 Jul 2026python-react60
12 Jul 2026python-react115
19 Jul 2026python-react155
26 Jul 2026python-react230
2 Aug 2026python-react190
9 Aug 2026python-react240
16 Aug 2026python-react230
23 Aug 2026python-react240
30 Aug 2026python-react250
6 Sept 2026python-react270
13 Sept 2026python-react290
20 Sept 2026python-react295
27 Sept 2026python-react325
4 Oct 2026python-react345
11 Oct 2026python-react255
18 Oct 2026python-react235
25 Oct 2026python-react155

By stack

How often this fragment stays in a default composition, or gets attached as an option.

python-api
Optional · attachedhidden: too few projects

– projects including the fragment

python-react
Optional · attached17%

730 projects including the fragment

Stacks projects · 28 days through 30 Oct 2026. Counts rounded to 5.

Data table
StackProjectsRoleShare
python-api–Optional · attached–
python-react730Optional · attached17%

Green rate with and without it

This compares projects; it isn't an effect of the fragment.

python-react

With

87%83–90%, n=450

Without

86%85–87%, n=2,300

Stacks projects · 28 days through 30 Oct 2026. Counts rounded to 5.

Data table
StackWithWithout
python-react87% (83–90%, n=450)86% (85–87%, n=2,300)

Often used with

Co-occurrence above the baseline, within a stack. Required fragment pairs are excluded.

Not enough runs in this breakdown yet.

Stacks projects · 28 days through 30 Oct 2026. Counts rounded to 5.

Computed 31 Oct 2026, through 30 Oct 2026. Numbers describe stacks projects, not the ecosystem.