Моя модель ORM (SqlAlchemy):
Код: Выделить всё
class BetaORM(Base):
__tablename__ = "betasignup"
email = Column(EmailType, primary_key=True)
fullname = Column(String, unique=False, index=False, nullable=True)
Код: Выделить всё
class BetaCreate(BaseModel):
email: EmailStr
fullname: Optional[str]
Код: Выделить всё
@app.post("/beta_signup")
def post_beta_signup(beta: schemas.BetaCreate, db: Session = Depends(get_db)):
return create_beta_signup(db=db,signup=beta)
Код: Выделить всё
def create_beta_signup(db: Session, signup: schemas.BetaCreate):
db_beta = schemas.BetaORM(**signup.dict())
ret_obj = db.merge(db_beta)
db.add(ret_obj)
db.commit()
return ret_obj
Подробнее здесь: https://stackoverflow.com/questions/631 ... in-fastapi