class Lizard(db.Model): __tablename__ = 'lizard' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(250), nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) picture_url = db.Column(db.String(500)) creation_instant = db.Column(db.DateTime(timezone=True), default=datetime.datetime.utcnow) hobby_relationship = db.relationship("Hobby", cascade="delete") @property def serialize(self): """Return object data in easily serializeable format""" return { 'name': self.name, 'id': self.id, 'picture_url': self.picture_url, 'creation_instant': self.creation_instant }
class ChangeLog(db.Model): __tablename__ = 'changelog' id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer) # user = db.relationship(User) lizard_name = db.Column(db.String(80)) lizard_id = db.Column(db.Integer) # lizard = db.relationship(Lizard) hobby_name = db.Column(db.String(80)) hobby_id = db.Column(db.Integer) # hobby = db.relationship(Hobby) update_instant = db.Column(db.DateTime(timezone=True), default=datetime.datetime.utcnow) # Possible actions are "new", "update", or "delete" action = db.Column(db.String(6)) # Possible tables are "lizard" or "hobby" table = db.Column(db.String(9))
class User(db.Model): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) lizards = db.relationship("Lizard", cascade="delete") hobbies = db.relationship("Hobby", cascade="delete") name = db.Column(db.String(80), nullable=False) email = db.Column(db.String(80)) picture = db.Column(db.LargeBinary) facebook_id = db.Column(db.String(80)) gplus_id = db.Column(db.String(80))
class Hobby(db.Model): __tablename__ = 'hobby' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) description = db.Column(db.String(250)) lizard_id = db.Column(db.Integer, db.ForeignKey('lizard.id')) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) picture_url = db.Column(db.String(500)) creation_instant = db.Column(db.DateTime(timezone=True), default=datetime.datetime.utcnow) @property def serialize(self): """Return object data in easily serializeable format""" return { 'name': self.name, 'description': self.description, 'id': self.id, 'picture_url': self.picture_url, 'creation_instant': self.creation_instant }
class GDP_Percap(db.Model): __tablename__ = 'gdp_percap' id = db.Column(db.Integer, primary_key=True) year = db.Column(db.Integer) gdp = db.Column(db.Integer)
class By_Income(db.Model): __tablename__ = 'by_income' id = db.Column(db.Integer, primary_key=True) year = db.Column(db.Integer) income_quintile = db.Column(db.Integer) income = db.Column(db.Integer) housing = db.Column(db.Integer) foodhome = db.Column(db.Integer) foodaway = db.Column(db.Integer) health = db.Column(db.Integer) alcbevg = db.Column(db.Integer) apparel = db.Column(db.Integer) trans = db.Column(db.Integer) entrtain = db.Column(db.Integer)
class Computer(db.Model): __tablename__ = 'AllComputers' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(20), unique=False, nullable = False) managed = db.Column(db.String(20), unique=False, nullable = False) username = db.Column(db.String(20), unique=False, nullable = False) model = db.Column(db.String(100), unique=False, nullable = False) department = db.Column(db.String(20), unique=False, nullable = True) building = db.Column(db.String(20), unique=False, nullable = True) mac_address = db.Column(db.String(20), unique=False, nullable = False) udid = db.Column(db.String(20), unique=False, nullable = False) serial_number = db.Column(db.String(20), unique=False, nullable = False) report_date_utc = db.Column(db.String(20), unique=False, nullable = False) report_date_epoch = db.Column(db.String(20), unique=False, nullable = False) def __repr__(self): return '{} {}'.format(self.id, self.username)