Last active
March 31, 2016 05:06
-
-
Save robert8138/7b794877c6fa86cf6d02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask.ext.sqlalchemy import SQLAlchemy | |
from sqlalchemy import Column, Integer, String, Date, Float | |
db = SQLAlchemy() | |
class Events(db.Model): | |
__tablename__ = 'events_full' | |
id = Column(Integer, primary_key=True) | |
date = Column(Date) | |
duration = Column(Float) | |
event_type = Column(String) | |
event_name = Column(String) | |
def __init__(self, date, duration, event_type, event_name): | |
self.date = date | |
self.duration = duration | |
self.event_type = event_type | |
self.event_name = event_name | |
@property | |
def serialize(self): | |
'''return as a json object so we can use it in RESTful API''' | |
return {'id': self.id, | |
'date': self.date.strftime("%Y-%m-%d"), | |
'duration': self.duration, | |
'event_type': self.event_type, | |
'event_name': self.event_name } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment