-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.py
69 lines (44 loc) · 1.14 KB
/
schema.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from typing import List, Optional
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
# class Questions(Base):
#__tablename__ = "Questions"
#id = Column(Integer, primary_key=True)
#question = Column(String)
#choices = relationship("Choices")
#topic_id = Column(Integer, ForeignKey('Topics.id'))
class QuestionsBase(BaseModel):
question: str
class QuestionsCreate(QuestionsBase):
pass
class Questions(QuestionsBase):
id: int
topic_id: int
choices: list
class Config:
orm_mode = True
# class Choices(Base):
# __tablename__ = "Choices"
# q_id = Column(Integer, ForeignKey('Questions.id'))
# choice = Column(String)
# choice_type = Column(Integer)
# answer = Column(Integer)
# id = Column('id', Integer, primary_key=True)
class ChoicesBase(BaseModel):
choice: int
choice_type: int
answer: int
class ChoicesCreate(ChoicesBase):
pass
class Choices(ChoicesBase):
q_id: int
id: int
class TopicsBase(BaseModel):
Name: str
class TopicsCreate(TopicsBase):
pass
class Topics(TopicsBase):
id: int
class Config:
orm_mode = True