class Term(db.Model): __tablename__ = 'wp_terms' id = db.Column('term_id', db.Integer, primary_key=True) name = db.Column('name', db.String) slug = db.Column('slug', db.String) term_group = db.Column( 'term_group', db.Integer) # this is unused and here only for completeness taxonomy_item = db.relationship('Taxonomy', primaryjoin="Taxonomy.term_id == Term.id", foreign_keys=id) type = association_proxy('taxonomy_item', 'taxonomy')
class Account(db.Model): __tablename__ = "account" id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(128)) password = db.Column(db.String(128)) created = db.Column(db.DateTime) def __init__(self, email, password, created): self.email = email self.password = password self.created = created def __repr__(self): return "<{0} joined at {1})>".format( self.email, util.format_datetime(self.created))
class Post(db.Model): __tablename__ = 'wp_posts' id = db.Column('ID', db.Integer, primary_key=True) content = db.Column('post_content', db.String) status = db.Column('post_status', db.String) parent = db.Column('post_parent', db.Integer) guid = db.Column('guid', db.String) type = db.Column('post_type', db.String)
class Location(db.Model): __tablename__ = 'location' id = db.Column(db.Integer, primary_key=True) device_id = db.Column(db.String) recorded_at = db.Column(db.String) location_type = db.Column(db.String) longitude = db.Column(db.Float) latitude = db.Column(db.Float) altitude = db.Column(db.Float) def __init__(self, device_id, recorded_at, location_type, longitude, latitude, altitude): self.device_id = device_id self.recorded_at = recorded_at self.location_type = location_type self.longitude = longitude self.latitude = latitude self.altitude = altitude @staticmethod def get_locations_by_device_id(device_id_search): return db.session.query(Location).filter_by(device_id=device_id_search)