Song的学习笔记

首页 新随笔 联系 管理

python fastapi schema和model的区别

To avoid confusion between the SQLAlchemy models and the Pydantic models, we will have the file model......

来自 fastapi 的文档 Create the Pydantic models

To avoid confusion between the SQLAlchemy models and the Pydantic models, we will have the file models.py with the SQLAlchemy models, and the file schemas.py with the Pydantic models.

These Pydantic models define more or less a "schema" (a valid data shape).

So this will help us avoiding confusion while using both.

大概意思就是:

  • schemas.py 放 pydantic 的模型
  • models.py 放 sqlalchemy、peewee 的模型
posted on 2023-11-21 22:01  Song的学习笔记  阅读(624)  评论(0)    收藏  举报