The easiest way to create your Restful CRUD APIs
Project description
CrudAPI: The easiest way to create your CRUD APIs
Combining the power of FastAPI and SQLModel, you'll only have to care about modeling your data and we'll take care of building up a RESTful API for it.
from typing import Optional
from sqlmodel import Field
from sqlmodel import SQLModel
from crudapi.api import CrudAPI
from crudapi.models.base import BaseModel
class BookUpdate(SQLModel, table=False):
description: Optional[str] = Field(nullable=True)
review: Optional[str] = Field(nullable=True)
class BookCreate(BookUpdate):
title: str = Field(nullable=False)
class Book(BookCreate, BaseModel, table=True):
__tablename__ = "books"
crud = CrudAPI(
orm_model=Book,
response_model=Book,
create_model=BookCreate,
update_model=BookUpdate,
title="Books",
)
you'll get, out of the box, a working crudapi with all these working REST endpoints:
- GET: /books
- POST: /books
- GET: /books/<id>
- PATCH: /books/<id>
- PUT: /books/<id>
- DELETE: /books/<id>
and because CrudAPI subclasses FastAPI you'll also get all the incredible features of this wonderful library, including automatic OpenAPI schema generation and a working SwaggerUI:
Development
We use Poetry for packaging and dependency management:
poetry install
poetry shell
We use Pytest for testing:
pytest
You can start a testing server running:
uvicorn tests.server:app --reload
Acknowledgments
This wouldn't be possible without the great people working in the following open source projects. Eternal thanks to all of them.
- SQLAlchemy "The database toolkit for python."
- Starlette "The little ASGI framework that shines."
- pydantic "Data validation and settings management using Python type hinting."
- FastAPI "FastAPI framework, high performance, easy to learn, fast to code, ready for production."
- SQLModel "SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness."
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file crudapi-0.3.0.tar.gz
.
File metadata
- Download URL: crudapi-0.3.0.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.9.7 Linux/5.8.0-1042-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50bc3d2dcb462234080055f9d04a964865bef9e6a2ec1bfcead5a78d8aba3a27 |
|
MD5 | e02d7133614872525c176f30fbf4a4ad |
|
BLAKE2b-256 | 186166c0f3e48bd8de3879160f7b9697fe7e1ca6c9b37d05e72aea5a1915f05e |
File details
Details for the file crudapi-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: crudapi-0.3.0-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.9.7 Linux/5.8.0-1042-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f49f15139e7cc9c9ee8b15d1188b156c8f0b43c7df96b224943c61bc00d36bd1 |
|
MD5 | 6a73ab6a5f293748d4bc65d5aa82a043 |
|
BLAKE2b-256 | 129b38f4973b82ce71f6928f843beed0efeaef00c08ffee90b92b7df0b05bf38 |