-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodels.py
64 lines (46 loc) · 1.65 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
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
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class Word(db.Model):
id = db.Column(db.Integer, primary_key=True)
value = db.Column(db.String(100))
transcription = db.Column(db.String(120))
created = db.Column(db.DateTime)
last_update = db.Column(db.DateTime)
picture_url = db.Column(db.String(80))
sound_url = db.Column(db.String(80))
translates = db.relationship('Translate', backref='word')
def __str__(self):
return self.value
class Translate(db.Model):
id = db.Column(db.Integer, primary_key=True)
value = db.Column(db.String(120))
votes = db.Column(db.Integer)
word_id = db.Column(db.Integer, db.ForeignKey('word.id'))
def __str__(self):
return self.value
class StopWord(db.Model):
word = db.Column(db.String(80), primary_key=True)
def __str__(self):
return self.value
class TranslatedWord(db.Model):
id = db.Column(db.Integer, primary_key=True)
value = db.Column(db.String(100))
transcription = db.Column(db.String(120))
sound_url = db.Column(db.String(80))
translates = db.relationship(
'TranslatedOption', backref='translated_word',
cascade='save-update, merge, delete')
def __str__(self):
return self.value
class TranslatedOption(db.Model):
id = db.Column(db.Integer, primary_key=True)
value = db.Column(db.String(120))
votes = db.Column(db.Integer)
translated_word_id = db.Column(db.Integer, db.ForeignKey(
'translated_word.id'))
def __str__(self):
return self.value
if __name__ == '__main__':
from server import app
with app.app_context():
db.create_all()