{"id":413945,"date":"2024-06-29T23:27:24","date_gmt":"2024-06-29T23:27:24","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=413945"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-29T23:27:24","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=413945","title":{"rendered":"<span>FastAPI \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 CRUD<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442, \u044d\u0442\u043e \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430 Habr, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043c\u0443-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e. \u041d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u044f \u043a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u0435\u043b\u0430\u043b \u043a\u0430\u043a\u043e\u0439-\u0442\u043e REST API \u0438 \u0432\u0434\u0440\u0443\u0433 \u043c\u0435\u043d\u044f \u043f\u043e\u0441\u0435\u0442\u0438\u043b\u0430 \u043c\u044b\u0441\u043b\u044c \u0447\u0442\u043e \u044f \u0447\u0442\u043e-\u0442\u043e \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043f\u0438\u0440\u0443\u044e \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u043a\u043e\u0434\u0430. \u0418 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c <a href=\"https:\/\/github.com\/dagolub\/fastapi-codegen\" rel=\"noopener noreferrer nofollow\">\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 <\/a> \u044d\u0442\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e.<\/p>\n<p>\u0421\u0440\u0430\u0437\u0443 \u043e\u0433\u043e\u0432\u043e\u0440\u044e\u0441\u044c \u0447\u0442\u043e \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <a href=\"https:\/\/github.com\/tiangolo\/full-stack-fastapi-postgresql\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/tiangolo\/full-stack-fastapi-postgresql<\/a> \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e backend\/app\/app \u0447\u0442\u043e \u0431\u044b \u0432\u0441\u0435 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e.<\/p>\n<p>\u0414\u0443\u043c\u0430\u044e \u0432 \u0447\u0438\u0441\u0442\u043e\u043c FastAPI \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0442\u0438\u043f\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 superuser \u0438 \u043e\u0431\u044b\u043a\u043d\u043e\u0432\u0435\u043d\u043d\u044b\u0439 user \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0435\u043d\u043d\u043e CRUD \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0432\u0443\u0445 \u044d\u0442\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u0414\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 CRUD \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c.<\/p>\n<pre><code class=\"python\">from sqlalchemy import Column, Integer, String from app.db.base_class import Base   class Category(Base):     id = Column(Integer, primary_key=True, index=True)     name = Column(String, nullable=False) <\/code><\/pre>\n<p>\u041d\u0430\u0437\u043e\u0432\u0435\u043c \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b models\/category.py<\/p>\n<p>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u044f \u043c\u0430\u0433\u0438\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u0441\u0435 endpoints\/crud\/schemas \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0438\u0437 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 backend\/app\/app \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code class=\"bash\">python3 codegen.py Category<\/code><\/pre>\n<p>\u041d\u0443\u0436\u043d\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c typer \u0438 jinja2 \u0447\u0442\u043e \u0431\u044b \u0441\u043a\u0440\u0438\u043f\u0442 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b.<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0444\u0430\u0439\u043b\u0438\u043a \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 codegen\/generated<\/p>\n<pre><code class=\"python\">from typing import Any, List  from fastapi import APIRouter, Depends, HTTPException from sqlalchemy.orm import Session from app import crud, models, schemas from app.api import deps from app.translate import _  router = APIRouter()   @router.get(\"\/\", response_model=List[schemas.Category]) def read_categories(     db: Session = Depends(deps.get_db),     skip: int = 0,     limit: int = 100,     current_user: models.User = Depends(deps.get_current_active_user), ) -> Any:     \"\"\"     Retrieve category.     \"\"\"     return crud.category.get_multi(db, skip=skip, limit=limit)   @router.post(\"\/\", response_model=schemas.Category) def create_category(     *,     db: Session = Depends(deps.get_db),     category_in: schemas.CategoryCreate,     current_user: models.User = Depends(deps.get_current_active_superuser), ) -> Any:     \"\"\"     Create new category.     \"\"\"      return crud.category.create(db=db, obj_in=category_in)   @router.get(\"\/{id}\", response_model=schemas.Category) def read_category(     id: int,     current_user: models.User = Depends(deps.get_current_active_superuser),     db: Session = Depends(deps.get_db), ) -> Any:     \"\"\"     Get a category.     \"\"\"     category = crud.category.get(db=db, id=id)     if not category:         raise HTTPException(             status_code=400, detail=_(\"Category doesn't exists\")         )     return category   @router.put(\"\/{id}\", response_model=schemas.Category) def update_category(     *,     db: Session = Depends(deps.get_db),     id: int,     category_in: schemas.CategoryUpdate,     current_user: models.User = Depends(deps.get_current_active_superuser), ) -> Any:     \"\"\"     Update a category.     \"\"\"     category = crud.category.get(db=db, id=id)     if not category:         raise HTTPException(             status_code=404,             detail=_(\"Category doesn't exists\"),         )     category = crud.category.update(db=db, db_obj=category, obj_in=category_in)     return category   @router.delete(\"\/{id}\", response_model=schemas.Category) def delete_category(     *,     db: Session = Depends(deps.get_db),     id: int,     current_user: models.User = Depends(deps.get_current_active_superuser), ) -> Any:     \"\"\"     Delete an category.     \"\"\"     category = crud.category.get(db=db, id=id)     if not category:         raise HTTPException(status_code=404, detail=_(\"Category doesn't exists\"))      return crud.category.remove(db=db, id=id)<\/code><\/pre>\n<p>\u0418 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0440\u0435\u043a\u0432\u0435\u0441\u0442:<\/p>\n<pre><code class=\"bash\">Install new files? [y\/N]:<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0434\u043e \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438\u0445 \u043f\u043e\u0434\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438 \u043d\u0430\u0436\u0430\u0442\u044c &#171;y&#187;<\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0447\u0442\u043e \u0431\u044b \u044d\u0442\u043e \u0432\u0441\u0435 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0434\u0432\u0430 \u0448\u0430\u0433\u0430 \u0447\u0435\u043a\u043d\u0443\u0442\u044c   app\/api\/api_v1\/api.py \u0442\u0430\u043c \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0432 models\/__init__.py \u0447\u0442\u043e \u0431\u044b \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b <\/p>\n<pre><code class=\"bash\">alembic revision --autogenerated -m \"new Model\"<\/code><\/pre>\n<p>\u0417\u0430\u0431\u044b\u043b \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 &#8212; \u044d\u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0434\u0438 \u043d\u043e\u0432\u044b\u0445 \u043c\u0435\u043c\u0431\u0435\u0440\u043e\u0432 <a href=\"https:\/\/t.me\/joinchat\/yZIKIgjhFZs4MDcy\" rel=\"noopener noreferrer nofollow\">FastAPI Ukraine<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/581150\/\"> https:\/\/habr.com\/ru\/articles\/581150\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442, \u044d\u0442\u043e \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430 Habr, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043c\u0443-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e. \u041d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u044f \u043a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u0435\u043b\u0430\u043b \u043a\u0430\u043a\u043e\u0439-\u0442\u043e REST API \u0438 \u0432\u0434\u0440\u0443\u0433 \u043c\u0435\u043d\u044f \u043f\u043e\u0441\u0435\u0442\u0438\u043b\u0430 \u043c\u044b\u0441\u043b\u044c \u0447\u0442\u043e \u044f \u0447\u0442\u043e-\u0442\u043e \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043f\u0438\u0440\u0443\u044e \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u043a\u043e\u0434\u0430. \u0418 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c <a href=\"https:\/\/github.com\/dagolub\/fastapi-codegen\" rel=\"noopener noreferrer nofollow\">\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 <\/a> \u044d\u0442\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e.<\/p>\n<p>\u0421\u0440\u0430\u0437\u0443 \u043e\u0433\u043e\u0432\u043e\u0440\u044e\u0441\u044c \u0447\u0442\u043e \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <a href=\"https:\/\/github.com\/tiangolo\/full-stack-fastapi-postgresql\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/tiangolo\/full-stack-fastapi-postgresql<\/a> \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e backend\/app\/app \u0447\u0442\u043e \u0431\u044b \u0432\u0441\u0435 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e.<\/p>\n<p>\u0414\u0443\u043c\u0430\u044e \u0432 \u0447\u0438\u0441\u0442\u043e\u043c FastAPI \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0442\u0438\u043f\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 superuser \u0438 \u043e\u0431\u044b\u043a\u043d\u043e\u0432\u0435\u043d\u043d\u044b\u0439 user \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0435\u043d\u043d\u043e CRUD \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0432\u0443\u0445 \u044d\u0442\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u0414\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 CRUD \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c.<\/p>\n<pre><code class=\"python\">from sqlalchemy import Column, Integer, String from app.db.base_class import Base   class Category(Base):     id = Column(Integer, primary_key=True, index=True)     name = Column(String, nullable=False) <\/code><\/pre>\n<p>\u041d\u0430\u0437\u043e\u0432\u0435\u043c \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b models\/category.py<\/p>\n<p>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u044f \u043c\u0430\u0433\u0438\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u0441\u0435 endpoints\/crud\/schemas \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0438\u0437 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 backend\/app\/app \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code class=\"bash\">python3 codegen.py Category<\/code><\/pre>\n<p>\u041d\u0443\u0436\u043d\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c typer \u0438 jinja2 \u0447\u0442\u043e \u0431\u044b \u0441\u043a\u0440\u0438\u043f\u0442 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b.<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0444\u0430\u0439\u043b\u0438\u043a \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 codegen\/generated<\/p>\n<pre><code class=\"python\">from typing import Any, List  from fastapi import APIRouter, Depends, HTTPException from sqlalchemy.orm import Session from app import crud, models, schemas from app.api import deps from app.translate import _  router = APIRouter()   @router.get(\"\/\", response_model=List[schemas.Category]) def read_categories(     db: Session = Depends(deps.get_db),     skip: int = 0,     limit: int = 100,     current_user: models.User = Depends(deps.get_current_active_user), ) -> Any:     \"\"\"     Retrieve category.     \"\"\"     return crud.category.get_multi(db, skip=skip, limit=limit)   @router.post(\"\/\", response_model=schemas.Category) def create_category(     *,     db: Session = Depends(deps.get_db),     category_in: schemas.CategoryCreate,     current_user: models.User = Depends(deps.get_current_active_superuser), ) -> Any:     \"\"\"     Create new category.     \"\"\"      return crud.category.create(db=db, obj_in=category_in)   @router.get(\"\/{id}\", response_model=schemas.Category) def read_category(     id: int,     current_user: models.User = Depends(deps.get_current_active_superuser),     db: Session = Depends(deps.get_db), ) -> Any:     \"\"\"     Get a category.     \"\"\"     category = crud.category.get(db=db, id=id)     if not category:         raise HTTPException(             status_code=400, detail=_(\"Category doesn't exists\")         )     return category   @router.put(\"\/{id}\", response_model=schemas.Category) def update_category(     *,     db: Session = Depends(deps.get_db),     id: int,     category_in: schemas.CategoryUpdate,     current_user: models.User = Depends(deps.get_current_active_superuser), ) -> Any:     \"\"\"     Update a category.     \"\"\"     category = crud.category.get(db=db, id=id)     if not category:         raise HTTPException(             status_code=404,             detail=_(\"Category doesn't exists\"),         )     category = crud.category.update(db=db, db_obj=category, obj_in=category_in)     return category   @router.delete(\"\/{id}\", response_model=schemas.Category) def delete_category(     *,     db: Session = Depends(deps.get_db),     id: int,     current_user: models.User = Depends(deps.get_current_active_superuser), ) -> Any:     \"\"\"     Delete an category.     \"\"\"     category = crud.category.get(db=db, id=id)     if not category:         raise HTTPException(status_code=404, detail=_(\"Category doesn't exists\"))      return crud.category.remove(db=db, id=id)<\/code><\/pre>\n<p>\u0418 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0440\u0435\u043a\u0432\u0435\u0441\u0442:<\/p>\n<pre><code class=\"bash\">Install new files? [y\/N]:<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0434\u043e \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438\u0445 \u043f\u043e\u0434\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438 \u043d\u0430\u0436\u0430\u0442\u044c &#171;y&#187;<\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0447\u0442\u043e \u0431\u044b \u044d\u0442\u043e \u0432\u0441\u0435 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0434\u0432\u0430 \u0448\u0430\u0433\u0430 \u0447\u0435\u043a\u043d\u0443\u0442\u044c   app\/api\/api_v1\/api.py \u0442\u0430\u043c \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0432 models\/__init__.py \u0447\u0442\u043e \u0431\u044b \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b <\/p>\n<pre><code class=\"bash\">alembic revision --autogenerated -m \"new Model\"<\/code><\/pre>\n<p>\u0417\u0430\u0431\u044b\u043b \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 &#8212; \u044d\u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0434\u0438 \u043d\u043e\u0432\u044b\u0445 \u043c\u0435\u043c\u0431\u0435\u0440\u043e\u0432 <a href=\"https:\/\/t.me\/joinchat\/yZIKIgjhFZs4MDcy\" rel=\"noopener noreferrer nofollow\">FastAPI Ukraine<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/581150\/\"> https:\/\/habr.com\/ru\/articles\/581150\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-413945","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/413945","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=413945"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/413945\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=413945"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=413945"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=413945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}