Skip to content

Instantly share code, notes, and snippets.

@cezarmezzalira
Created November 21, 2023 12:50
Show Gist options
  • Save cezarmezzalira/a6feb6004890d0fcf33028fabe09ac19 to your computer and use it in GitHub Desktop.
Save cezarmezzalira/a6feb6004890d0fcf33028fabe09ac19 to your computer and use it in GitHub Desktop.
RACE API Models
from typing import List
from sqlmodel import Field, Relationship, SQLModel
class Provas(SQLModel, table=True):
id: int = Field(default=None, primary_key=True)
descricao: str
data_prova: str
q1: str
q2: str
q3: str
q4: str
q5: str
q6: str
q7: str
q8: str
q9: str
q10: str
resultados: List["Resultados"] = Relationship(back_populates="provas")
from typing import Optional
from sqlmodel import Field, Relationship, SQLModel
from src.models.provas_model import Provas
class Resultados(SQLModel, table=True):
id: int = Field(default=None, primary_key=True)
nome: str
q1: str
q2: str
q3: str
q4: str
q5: str
q6: str
q7: str
q8: str
q9: str
q10: str
nota: float = Optional[float]
prova_id: int = Field(nullable=False, foreign_key="provas.id")
provas: Optional[Provas] = Relationship(back_populates="resultados")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment