-
Notifications
You must be signed in to change notification settings - Fork 0
/
datamodel.py
71 lines (58 loc) · 1.84 KB
/
datamodel.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
70
71
from peewee import *
db = SqliteDatabase(None)
class Citizen(Model):
citizen_id = CharField(primary_key=True)
class Meta:
database = db
class Trip(Model):
#trip_id = IntegerField(primary_key=True)
trip_id = PrimaryKeyField()
citizen_id = ForeignKeyField(Citizen, backref = 'trips')
start_coordinate = CharField()
start_address = CharField()
stop_coordinate = CharField()
stop_address = CharField()
start_timestamp = DateTimeField()
stop_timestamp = DateTimeField()
transportation_mode = CharField(null=True)
segment_confidence = FloatField(null=True)
transportation_confidence = FloatField(null=True)
path = TextField(null=True)
json_file_path = TextField(null=True)
class Meta:
database = db
class Question(Model):
question_id = AutoField(primary_key=True)
citizen_id = ForeignKeyField(Citizen, backref = 'questions')
task_id = CharField()
trip_id = ForeignKeyField(Trip, backref='trip')
#All the JSON
question_json = TextField()
update_url = CharField()
answer_file_path = TextField(null=True)
diff_file_path = TextField(null=True)
answer_json = TextField(null=True)
answer_code = CharField(null=True)
class Meta:
database = db
class QuestionFailsafe(Model):
question_id = AutoField(primary_key=True)
citizen_id = ForeignKeyField(Citizen, backref = 'questions')
task_id = CharField()
#question_json = TextField()
date = DateTimeField()
file_paths = TextField(null=True)
answer_json = TextField(null=True)
class Meta:
database = db
def initialize(dbname):
db.init(dbname)
db.connect()
db.create_tables([Citizen,Trip,Question])
db.close()
def main():
db.init('')
db.connect()
db.create_tables([Citizen,Trip,Question])
db.close()
if __name__ == "__main__": main()