-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
34 lines (29 loc) · 831 Bytes
/
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
# -*- coding: utf-8 -*-
'''
:file: models.py
:author: -Farmer
:url: https://blog.farmer233.top
:date: 2021/09/21 13:02:01
'''
# 解决无代码提示
import sqlalchemy as sa
from datetime import datetime
from app.extensions import db
GMT_FORMAT = '%a, %d %b %Y %H:%M:%S GMT'
class TodoList(db.Model):
id = sa.Column(sa.Integer, primary_key=True)
task = sa.Column(sa.String(255))
completed = sa.Column(sa.Boolean, default=False)
time = sa.Column(
sa.DateTime, default=datetime.now, onupdate=datetime.now)
def save_task(self) -> bool:
return False
try:
db.session.add(self)
db.session.commit()
except Exception:
return False
return True
@staticmethod
def get_tasks():
return TodoList.query.all()