fastapi-ormar-utilities-0.1.1
توضیحات
Small, but usefull library for interaction with Ormar ORM
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | fastapi-ormar-utilities-0.1.1 |
| نام | fastapi-ormar-utilities |
| نسخه کتابخانه | 0.1.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Vladislav Isakov |
| ایمیل نویسنده | vladisa88@gmail.com |
| آدرس صفحه اصلی | https://github.com/vladisa88/fastapi-ormar-utilities |
| آدرس اینترنتی | https://pypi.org/project/fastapi-ormar-utilities/ |
| مجوز | - |
# FASTAPI-ORMAR-UTILITIES

## Small package for better interaction with Ormar ORM.
### This package makes your views cleaner
### Features:
* Fully async
* Compatible with FastAPI
* In my opinion Ormar is the best ORM for FastAPI
* Support `select_related()` method
* Handle `Not found` exceptions
### Install with pip
```
pip install fastapi-ormar-utilities[all]
```
### Example usage:
```python
from fastapi import APIRouter, Depends
from fastapi_ormar_utilities import Base
from .models import Item # import Ormar model
from .schemas import ItemCreate # import Pydantic model
router = APIRouter()
class ItemService(Base):
model = Item
@router.get('/')
async def get_items(
service: ItemService = Depends()
):
return await service.fetch_all()
@router.get('/')
async def get_items_with_related(
service: ItemService = Depends()
):
# if you want to add related field to the query
return await service.fetch_all(related_field='some_field')
@router.post('/')
async def create_item(
item_data: ItemCreate,
service: ItemService = Depends()
):
return await service.create(item_data)
```
نیازمندی
| مقدار | نام |
|---|---|
| - | pydantic |
| - | ormar |
| - | fastapi |
نحوه نصب
نصب پکیج whl fastapi-ormar-utilities-0.1.1:
pip install fastapi-ormar-utilities-0.1.1.whl
نصب پکیج tar.gz fastapi-ormar-utilities-0.1.1:
pip install fastapi-ormar-utilities-0.1.1.tar.gz