class Place(db.Model): __tablename__ = 'places' place_id = db.Column(db.String(20), primary_key=True) name = db.Column(db.String(50)) latitude = db.Column(db.Float) longitude = db.Column(db.Float) country_code = db.Column( db.String(5), db.ForeignKey('countries.country_code'))
class TweetHashtag(db.Model): __tablename__ = 'tweet_hashtag' tweet_id = db.Column(db.BigInteger, db.ForeignKey( 'base_tweets.tweet_id'), primary_key=True) hashtag = db.Column(db.String(50), db.ForeignKey( 'hashtags.hashtag'), primary_key=True) tweet_id_relationship = db.relationship(BaseTweet, backref='tweet_hashtag') hashtag_relationship = db.relationship(Hashtag, backref='tweet_hashtag')
class BaseTweet(db.Model): __tablename__ = 'base_tweets' tweet_id = db.Column(db.BigInteger, primary_key=True) tweet_id_str = db.Column(db.String(20)) tweet_text = db.Column(db.Text) source = db.Column(db.String(512)) favorited = db.Column(db.Boolean) retweeted = db.Column(db.Boolean) favorite_count = db.Column(db.Integer) retweet_count = db.Column(db.Integer) result_type = db.Column(db.String(20)) created_at = db.Column(db.DateTime) lang = db.Column(db.String(10)) possibly_sensitive = db.Column(db.Boolean) place_id = db.Column(db.String(20), db.ForeignKey('places.place_id')) place = db.relationship('Place', backref='base_tweets') hashtags = db.relationship( 'Hashtag', secondary='tweet_hashtag', backref='base_tweets')
class User(db.Model): __tablename__ = 'users' id = db.Column(db.BigInteger, primary_key=True) id_str = db.Column(db.String(20)) name = db.Column(db.String(60)) screen_name = db.Column(db.String(60)) followers_count = db.Column(db.Integer) verified = db.Column(db.Boolean) profile_image_url_https = db.Column(db.String(512)) favourites_count = db.Column(db.Integer) # user_type = db.Column(postgresql.ENUM( # 'tweet_user', 'retweeted_user', 'mentioned_user', name='user_type_enum')) tweets = db.relationship( 'BaseTweet', secondary='tweet_users', backref='tweet_users') retweets = db.relationship( 'BaseTweet', secondary='retweeted_users', backref='retweeted_users') mentioned_tweets = db.relationship( 'BaseTweet', secondary='mentioned_users', backref='mentioned_users')
class Country(db.Model): __tablename__ = "countries" country_code = db.Column( db.String(5), primary_key=True) country = db.Column(db.String(50))
class TBDData(db.Model): __tablename__ = 'tbd_data' entity = db.Column(db.String(512), primary_key=True) identifier = db.Column(db.String(512), primary_key=True) identifier_value = db.Column(db.String(512), primary_key=True)
class Log(db.Model): __tablename__ = 'log' datetime = db.Column(db.DateTime, primary_key=True) info = db.Column(db.String(512))
class BadWord(db.Model): __tablename__ = 'bad_words' bad_word = db.Column(db.String(50), primary_key=True)
class Hashtag(db.Model): __tablename__ = 'hashtags' hashtag = db.Column(db.String(50), primary_key=True) frequency = db.Column(db.Integer)