关于python:fastapi-中的-schemas-和-models-的区别

来自 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 的模型

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理