Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

155
Vistas
FastAPI Crud design

I'm working on a Restful API using FastAPI and pydantic and postgres. I'm looking for schema design that will allow me to get data from user in a POST\PUT requests, enrich the data (default values that shouldn't be set by user or other columns that are deduced by given data), and then insert it to DB.

The project generator (see reference) suggests using schemas UserCreate\UserUpdate etc. as input to POST \ PUT routes. These objects are passed, in turn, to crud class method that creates\updates the object in the DB. This design will not work since the crud class method needs more information.

Example: In order to create a user, name, height and weight are required.

class UserCreate(BaseMethod):
    name: str
    height: integer
    weight: float

User model in database

class User(Model):
    name = Column()
    height = Column()
    weight = Column()
    bmi = Column()
    

Crud method need to get name, height, weight and BMI. How do I design my schemas in a way that will make this process as clean as possible?

PS: This is a simple example, I'm not looking for a solution in Database level (I guess that in some databases I can automatically update a column based on other column).

Project Generator Reference: https://github.com/tiangolo/full-stack-fastapi-postgresql/tree/master

Thanks

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda