Pydantic Model vs SQLAlchemy Model

Pydantic Model

  • Schema/Pydantic Models define the structure of a request & response

  • This ensures that when a user wants to create a post, the request will only go through if has a "title" and "content" in the body (as defined via Pydantic)

SQLAlchemy Model

  • Responsible for defining the columns of our "posts" table within Postgres

  • Is used to query, create, delete, update entries within the database

Last updated