fastapi-postgres-repository

Manage PostgreSQL repositories for FastAPI with bulk upsert and soft delete filtering.

3|Updated Jan 20, 2026
One-click install
npx skills add https://github.com/agusmdev/burntop --skill fastapi-postgres-repository
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fastapi-postgres-repository
Source: https://github.com/agusmdev/burntop/tree/main/.claude/skills/fastapi-postgres-repository
Command: npx skills add https://github.com/agusmdev/burntop --skill fastapi-postgres-repository

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a reusable PostgreSQL-backed repository layer for FastAPI apps, enabling consistent data access patterns and advanced features without duplicating code.

Core Features & Use Cases

  • CRUD operations based on a flexible base repository
  • Bulk upsert using ON CONFLICT for efficient batch inserts and updates
  • Soft delete filtering with optional restoration support
  • Integration with fastapi-pagination and fastapi-filter for paginated, queryable results
  • Easy extension by creating entity-specific repositories

Quick Start

Create your first repository by inheriting from PostgresRepository and supplying your SQLAlchemy model and Pydantic schemas. Use bulk_upsert to insert or update multiple records in a single database round trip. Apply soft delete operations and leverage paginated queries in your FastAPI endpoints.

Frequently Asked Questions about fastapi-postgres-repository

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement bulk upsert in a FastAPI PostgreSQL repository?

Bulk upsert in a FastAPI PostgreSQL repository uses the ON CONFLICT SQL clause to insert or update multiple records in a single database round trip. This approach leverages SQLAlchemy AsyncSession to efficiently handle batch data synchronization.

What is the best way to add soft delete filtering to SQLAlchemy async models?

Soft delete filtering for SQLAlchemy async models is handled automatically via a SoftDeleteMixin. This mixin intercepts queries to exclude deleted records natively, while also providing optional restoration support to recover soft-deleted entries when needed.

How do I set up paginated and filtered CRUD endpoints in FastAPI with SQLAlchemy?

Paginated and filtered CRUD endpoints in FastAPI are set up by integrating fastapi-pagination and fastapi-filter with your SQLAlchemy AsyncSession. The repository layer connects these libraries to provide seamless, queryable data access without duplicating code.

Can I use fastapi-pagination with a custom repository pattern for PostgreSQL?

Yes, fastapi-pagination integrates seamlessly with a custom PostgreSQL repository pattern built on SQLAlchemy AsyncSession. The repository handles the data access logic, while fastapi-pagination manages the pagination constraints and response formatting.

How do I create an entity-specific repository extending a FastAPI base repository?

You create an entity-specific repository by inheriting from the flexible PostgresRepository base class and supplying your specific SQLAlchemy model and Pydantic schemas. This allows easy extension for custom data access while reusing bulk upsert and soft delete features.

Does soft delete in this repository pattern support restoring deleted records?

Yes, soft delete in this repository pattern supports optional restoration of deleted records. The SoftDeleteMixin automatically filters deleted entries from standard queries while retaining the ability to recover them when business logic requires it.