-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
31 lines (24 loc) · 989 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
from app import db
from sqlalchemy import text
class Service(db.Model):
__tablename__ = 'service'
sqlite_autoincrement=True
id = db.Column(db.Integer(), primary_key=True)
name = db.Column(db.String(64), unique=False)
service_type = db.Column(db.String(64))
house = db.Column(db.String(64), unique=False)
street = db.Column(db.String(120), unique=False)
notes = db.Column(db.String(1000), unique=False)
phone = db.Column(db.String(64), unique=False)
website = db.Column(db.String(64), unique=False)
schedule = db.relationship('Schedule', backref='service')
def __repr__(self):
return '<Service %r>' % (self.name)
def get_id(self):
return str(self.id) # python 3
class Schedule(db.Model):
__tablename__ = 'schedule'
id = db.Column(db.Integer, primary_key = True)
open_on = db.Column(db.DateTime)
close_on = db.Column(db.DateTime)
service_id = db.Column(db.Integer, db.ForeignKey('service.id'))