generated from app-generator/jinja-atlantis-dark
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmodels.py
33 lines (24 loc) · 891 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
# -*- encoding: utf-8 -*-
"""
Copyright (c) 2019 - present AppSeed.us
"""
from app import db
class Stats(db.Model):
id = db.Column(db.Integer, primary_key=True )
month = db.Column(db.String(64), unique=True )
sold_units = db.Column(db.Integer )
total_sales = db.Column(db.Integer )
def __init__(self, id, month, sold_units, total_sales):
self.id = id
self.month = month
self.sold_units = sold_units
self.total_sales = total_sales
def __repr__(self):
return self.month + ' = ' + str(self.sold_units) + '/ ' + str(self.total_sales)
# Optional helper
def save(self):
# inject self into db session
db.session.add ( self )
# commit change and save the object
db.session.commit( )
return self