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
Or use the terminal
npx @steamfield/stacks add postgres| Step | Phase | Layer | Command |
|---|---|---|---|
| db-up | setup | install | make db-up |
| db-migrate | setup | install | make db-migrate |
| db-down | teardown | install | make 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.
- python-api
- python-react
- python-api
- python-react
Stacks projects per UTC week through 30 Oct 2026. Published stack counts only.
Data table
| Week ending | Stack | Projects |
|---|---|---|
| 5 Jul 2026 | python-api | – |
| 12 Jul 2026 | python-api | – |
| 19 Jul 2026 | python-api | – |
| 26 Jul 2026 | python-api | – |
| 2 Aug 2026 | python-api | – |
| 9 Aug 2026 | python-api | – |
| 16 Aug 2026 | python-api | – |
| 23 Aug 2026 | python-api | – |
| 30 Aug 2026 | python-api | – |
| 6 Sept 2026 | python-api | – |
| 13 Sept 2026 | python-api | – |
| 20 Sept 2026 | python-api | – |
| 27 Sept 2026 | python-api | – |
| 4 Oct 2026 | python-api | – |
| 11 Oct 2026 | python-api | – |
| 18 Oct 2026 | python-api | – |
| 25 Oct 2026 | python-api | – |
| 5 Jul 2026 | python-react | 60 |
| 12 Jul 2026 | python-react | 115 |
| 19 Jul 2026 | python-react | 155 |
| 26 Jul 2026 | python-react | 230 |
| 2 Aug 2026 | python-react | 190 |
| 9 Aug 2026 | python-react | 240 |
| 16 Aug 2026 | python-react | 230 |
| 23 Aug 2026 | python-react | 240 |
| 30 Aug 2026 | python-react | 250 |
| 6 Sept 2026 | python-react | 270 |
| 13 Sept 2026 | python-react | 290 |
| 20 Sept 2026 | python-react | 295 |
| 27 Sept 2026 | python-react | 325 |
| 4 Oct 2026 | python-react | 345 |
| 11 Oct 2026 | python-react | 255 |
| 18 Oct 2026 | python-react | 235 |
| 25 Oct 2026 | python-react | 155 |
By stack
How often this fragment stays in a default composition, or gets attached as an option.
Stacks projects · 28 days through 30 Oct 2026. Counts rounded to 5.
Data table
| Stack | Projects | Role | Share |
|---|---|---|---|
| python-api | – | Optional · attached | – |
| python-react | 730 | Optional · attached | 17% |
Green rate with and without it
This compares projects; it isn't an effect of the fragment.
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
| Stack | With | Without |
|---|---|---|
| python-react | 87% (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.