-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
48 lines (31 loc) · 1.04 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
from datetime import datetime
from peewee import *
DATABASE = SqliteDatabase('fcc_api.db')
class Url(Model):
original_url = CharField()
created_at = DateTimeField(default=datetime.now)
class Meta:
database = DATABASE
class ImageSearch(Model):
search_query = CharField()
created_at = DateTimeField(default=datetime.now)
class Meta:
database = DATABASE
class ExerciseUser(Model):
username = CharField(unique=True)
created_at = DateTimeField(default=datetime.now)
class Meta:
database = DATABASE
class Exercise(Model):
"""Exercises that can be associated with each exercise user."""
exercise_user = ForeignKeyField(ExerciseUser, backref='exercises')
description = CharField()
duration = IntegerField()
date = DateField(null=True)
created_at = DateTimeField(default=datetime.now)
class Meta:
database = DATABASE
def initialize():
DATABASE.connect()
DATABASE.create_tables([Url, ImageSearch, ExerciseUser, Exercise], safe=True)
DATABASE.close()