-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.py
42 lines (30 loc) · 1007 Bytes
/
model.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
from peewee import Model, CharField, DateTimeField, ForeignKeyField
import os
#from playhouse.sqlite_ext import SqliteExtDatabase
#db = SqliteExtDatabase('my_database.db')
# heroku run -s free -- python setup.py
from playhouse.db_url import connect
db = connect(os.environ.get('DATABASE_URL', 'sqlite:///my_database.db'))
class User(Model):
name = CharField(max_length=255, unique=True)
password = CharField(max_length=255)
class Meta:
database = db
class Task(Model):
name = CharField(max_length=255)
performed = DateTimeField(null=True)
performed_by = ForeignKeyField(rel_model=User, null=True)
class Meta:
database = db
# class Context(BaseModel):
# name = CharField(max_length=255)
#
#
# class ContextTask(BaseModel):
# context_id = IntegerField() # foreign key into context
# task_id = IntegerField() # foreign key into task
#
# class Meta:
# primary_key = CompositeKey(
# 'context_id', 'task_id'
# )