Registry / web-framework / fastcrud

fastcrud

JSON →
library0.22.2pypypi✓ verified 86d ago

FastCRUD is a Python package for FastAPI, offering robust async CRUD operations and flexible endpoint creation utilities. Built on SQLAlchemy, it supports SQLModel and provides automatic relationship detection, pagination, filtering, and more. Current version is 0.21.0, with releases every few months; Python 3.10+ required.

pip install fastcrud
INSTALL
IMPORT
SIG · FASTCRUD
F
fastcrud
web-frameworkpythonv0.22.2
Install
5.6s avg
Import
2132ms
Disk
57MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.22.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 2.238s · 58.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 5.6s · import 2.025s · 56MB
57MB installed
● package 57MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FastCRUD
from fastcrud import FastCRUD
from fastcrud.crud import FastCRUD
In older versions, the main class was under fastcrud.crud; now directly from fastcrud.
PaginatedListResponse
from fastcrud import PaginatedListResponse
from fastcrud.paginated import PaginatedListResponse
The fastcrud.paginated module was removed in v0.20.0. Import from top-level fastcrud instead.
endpoint_creator
from fastcrud import endpoint_creator
No common wrong import; just use from fastcrud.

Minimal FastAPI app with SQLAlchemy and FastCRUD to create an item.

from fastapi import FastAPI from pydantic import BaseModel from sqlalchemy import Column, Integer, String, create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker from fastcrud import FastCRUD # Setup SQLAlchemy Base = declarative_base() class Item(Base): __tablename__ = 'items' id = Column(Integer, primary_key=True) name = Column(String) engine = create_engine('sqlite:///./test.db') Base.metadata.create_all(bind=engine) SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) app = FastAPI() crud = FastCRUD(Item) @app.post('/items/') async def create_item(name: str): db = SessionLocal() result = await crud.create(db=db, object={'name': name}) db.close() return result
Debug
Known issues
breakingIn v0.20.0, the create() method no longer returns the SQLAlchemy model when schema_to_select is not provided. It returns None instead, for consistency with other CRUD methods.
fix
To retrieve the created model, either pass a schema_to_select or explicitly call get() after create().
affects: >=0.20.0
breakingPython 3.9 support was dropped in v0.21.0. Minimum Python version is now 3.10.
fix
Upgrade Python to 3.10 or later.
affects: >=0.21.0
deprecatedThe fastcrud.paginated module is deprecated and was removed in v0.20.0. Use imports from fastcrud directly.
fix
Change 'from fastcrud.paginated import PaginatedListResponse' to 'from fastcrud import PaginatedListResponse'.
affects: >=0.19.0, <0.20.0
gotchaThe create() method triggers a deprecation warning if called without schema_to_select in v0.19.x, and returns None in v0.20+. If you rely on the returned model, you must update your code.
fix
Provide schema_to_select parameter to create() or switch to get() after create.
affects: >=0.19.2, <0.20.0
gotchaAutomatic relationship detection (include_relationships=True) is new in v0.21.0. In earlier versions, you had to manually configure joins. If upgrading, review your code that manually sets up relationships.
fix
Set include_relationships=True in your routes to leverage automatic detection, or keep manual configuration.
affects: <0.21.0
Errors
Common errors & fixes
type object 'PaginatedListResponse' has no attribute '__pydantic_model__'
Importing PaginatedListResponse from fastcrud.paginated which was removed in v0.20.0.
fix
Change import to 'from fastcrud import PaginatedListResponse'.
AttributeError: 'NoneType' object has no attribute 'id' (when accessing result.id after create())
create() without schema_to_select returns None in v0.20.0+; previously it returned the model.
fix
Either pass schema_to_select to create() or call get() after create(): result = await crud.create(db, object=item_data, schema_to_select=ItemSchema)
ImportError: cannot import name 'FastCRUD' from 'fastcrud.crud'
In older installations, the import path changed; FastCRUD is now directly from fastcrud.
fix
Use 'from fastcrud import FastCRUD' instead of 'from fastcrud.crud import FastCRUD'.
Upgrade
Version history
0.22.2latest on PyPI · released May 28, 2026
Audit
Dependencies
fastapirequiredCore web framework dependency for endpoints
sqlalchemyrequiredORM dependency for async CRUD operations
sqlmodeloptionalOptional SQLModel integration for FastCRUD
Agent activity
6 hits · last 30 days
node
6
Resources
fastcrud — pip install fastcrud · libregistry