Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

150
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda