Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!