class UserLocations(db.Model): __tablename__ = "UserLocations" x = db.Column(db.Integer, primary_key=True, autoincrement=True) uid = db.Column(db.Integer) l_id = db.Column(db.Integer) current = db.Column(db.Boolean)
class User(db.Model): id = db.Column(db.Integer, primary_key=True) fullname = db.Column(db.String(200)) email = db.Column(db.String(100), unique=True) username = db.Column(db.String(100), unique=True) password = db.Column(db.String(200)) def __init__(self, fullname, email, username, password): self.fullname = fullname self.email = email self.username = username self.password = password
class Score(db.Model): """ Superclass that represent a similarity score between two articles (id, referred_id) """ __tablename__ = "score" relation = db.Column(db.Integer, primary_key=True) id = db.Column(ForeignKey("score.id")) referred_id = db.Column(ForeignKey("score.referred_id")) relationship("Article", primaryjoin="Score.id == Article.id") relationship("Article", primaryjoin="Score.referred_id == Article.id") score = db.Column(db.Float) def __init__(self, this_id, referred_id): self.id = this_id self.referred_id = referred_id @staticmethod def update_data(session, dataset, mode, tablename): print(f"Inserting data into table {tablename}") ospaths = get_paths() session = ospaths["datadir"] + session + "/" df = get_df(session + dataset) df.to_sql(name=tablename, con=db.engine, index=False, if_exists=mode)
class User(UserMixin, db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(64), index=True, unique=True) email = db.Column(db.String(120), index=True, unique=True) password_hash = db.Column(db.String(128)) about_me = db.Column(db.String(140)) last_seen = db.Column(db.DateTime, default=datetime.now(timezone.utc)) def __repr__(self): return '<User {}>'.format(self.username) def set_password(self, password): self.password_hash = generate_password_hash(password) def check_password(self, password): return check_password_hash(self.password_hash, password)
class Humidity(db.Model): __tablename__ = "Humidity" l_id = db.Column(db.Integer, primary_key=True, autoincrement=True) h0 = db.Column(db.Float, unique=False, nullable=True) h1 = db.Column(db.Float, unique=False, nullable=True) h2 = db.Column(db.Float, unique=False, nullable=True) h3 = db.Column(db.Float, unique=False, nullable=True) h4 = db.Column(db.Float, unique=False, nullable=True) h5 = db.Column(db.Float, unique=False, nullable=True) h6 = db.Column(db.Float, unique=False, nullable=True) h7 = db.Column(db.Float, unique=False, nullable=True) h8 = db.Column(db.Float, unique=False, nullable=True) h9 = db.Column(db.Float, unique=False, nullable=True) h10 = db.Column(db.Float, unique=False, nullable=True) h11 = db.Column(db.Float, unique=False, nullable=True) h12 = db.Column(db.Float, unique=False, nullable=True) h13 = db.Column(db.Float, unique=False, nullable=True) h14 = db.Column(db.Float, unique=False, nullable=True) h15 = db.Column(db.Float, unique=False, nullable=True) h16 = db.Column(db.Float, unique=False, nullable=True) h17 = db.Column(db.Float, unique=False, nullable=True) h18 = db.Column(db.Float, unique=False, nullable=True) h19 = db.Column(db.Float, unique=False, nullable=True) h20 = db.Column(db.Float, unique=False, nullable=True) h21 = db.Column(db.Float, unique=False, nullable=True) h22 = db.Column(db.Float, unique=False, nullable=True) h23 = db.Column(db.Float, unique=False, nullable=True) time = db.Column(db.String, unique=False, nullable=True)
class User(db.Model): __tablename__ = "User" uid = db.Column(db.Integer, autoincrement=True, primary_key=True) username = db.Column(db.String)
class Temperature(db.Model): __tablename__ = "Temperature" l_id = db.Column(db.Integer, primary_key=True, autoincrement=True) t0 = db.Column(db.Float, unique=False, nullable=True) t1 = db.Column(db.Float, unique=False, nullable=True) t2 = db.Column(db.Float, unique=False, nullable=True) t3 = db.Column(db.Float, unique=False, nullable=True) t4 = db.Column(db.Float, unique=False, nullable=True) t5 = db.Column(db.Float, unique=False, nullable=True) t6 = db.Column(db.Float, unique=False, nullable=True) t7 = db.Column(db.Float, unique=False, nullable=True) t8 = db.Column(db.Float, unique=False, nullable=True) t9 = db.Column(db.Float, unique=False, nullable=True) t10 = db.Column(db.Float, unique=False, nullable=True) t11 = db.Column(db.Float, unique=False, nullable=True) t12 = db.Column(db.Float, unique=False, nullable=True) t13 = db.Column(db.Float, unique=False, nullable=True) t14 = db.Column(db.Float, unique=False, nullable=True) t15 = db.Column(db.Float, unique=False, nullable=True) t16 = db.Column(db.Float, unique=False, nullable=True) t17 = db.Column(db.Float, unique=False, nullable=True) t18 = db.Column(db.Float, unique=False, nullable=True) t19 = db.Column(db.Float, unique=False, nullable=True) t20 = db.Column(db.Float, unique=False, nullable=True) t21 = db.Column(db.Float, unique=False, nullable=True) t22 = db.Column(db.Float, unique=False, nullable=True) t23 = db.Column(db.Float, unique=False, nullable=True) time = db.Column(db.String, unique=False, nullable=True)
class Locations(db.Model): __tablename__ = "Locations" l_id = db.Column(db.Integer, primary_key=True, autoincrement=True) location = db.Column(db.String)
class Article(db.Model): """ A model that describes an article. Does not separate blogs and news articles, or standalones or compilations. """ __tablename__ = "article" id = db.Column(db.String, db.ForeignKey("score.id"), db.ForeignKey("score.referred_id"), primary_key=True) article_url = db.Column(db.String) title = db.Column(db.String) author = db.Column(db.String) author_bio = db.Column(db.String) text = db.Column(db.String) date = db.Column(db.String) time = db.Column(db.String) category = db.Column(db.String) subcategory = db.Column(db.String) image_url = db.Column(db.String) type = db.Column(db.String) subtype = db.Column(db.String) def __repr__(self): return '<User {}>'.format(self.id) @staticmethod def update_data(session, dataset): print(f"Inserting data into table article") ospaths = get_paths() session = ospaths["datadir"] + session + "/" df = get_df(session + dataset, drop_nans=True) df.to_sql(name="article", con=db.engine, index=False, if_exists="replace")