-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
39 lines (27 loc) · 1.02 KB
/
models.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
from sqlalchemy import Column, Integer, String, JSON, ForeignKey, DateTime, func
from sqlalchemy.orm import relationship
from database import Base
class Answers(Base):
__tablename__ = 'answers'
id = Column(Integer, primary_key=True, autoincrement=True)
time = Column(DateTime, server_default=func.now())
answers = Column(JSON)
survey_id = Column(Integer, ForeignKey('surveys.id'))
survey = relationship('Surveys')
class Surveys(Base):
__tablename__ = 'surveys'
id = Column(Integer, primary_key=True, autoincrement=True)
title = Column(String)
start = Column(Integer)
class Questions(Base):
__tablename__ = "questions"
id = Column(Integer, primary_key=True, autoincrement=True)
nextid = Column(Integer)
yes = Column(Integer)
no = Column(Integer)
type = Column(String)
question = Column(String)
answers = Column(JSON)
validation = Column(String)
survey_id = Column(Integer, ForeignKey('surveys.id'))
survey = relationship('Surveys', backref='questions')