示例#1
0
class BaseAttr(db.Model):
    __abstract__ = True
    __table_args__ = {"schema": "attrs"}
    id = db.Column(db.String(10), primary_key=True)
    name = db.Column(db.String())
    HEADERS = ["id", "name"]
    median_moe = 0

    @classmethod
    def get_supported_levels(cls):
        return {}

    def serialize(self):
        return {
            key: val
            for key, val in self.__dict__.items() if not key.startswith("_")
        }

    def data_serialize(self):
        return [self.id, self.name]

    def __repr__(self):
        return '<{}, id: {}, name: {}>'.format(self.__class__, self.id,
                                               self.name)

    @staticmethod
    def is_attr():
        return True
示例#2
0
class Survey_Ygl(BasePoverty, PovertyValues):
    __tablename__ = "survey_ygl"
    median_moe = 2

    year = db.Column(db.Integer(), primary_key=True)
    poverty_geo = db.Column(db.String(), primary_key=True)
    poverty_level = db.Column(db.String(), primary_key=True)
    geo = column_property(PovertyXWalk.geo)

    @classmethod
    def get_supported_levels(cls):
        base_levels = super(Survey_Ygl, cls).get_supported_levels()
        return dict(base_levels, **{POVERTY_LEVEL: [ALL, PPP1, PPP2]})
示例#3
0
class Crop(BaseAttr, BaseModel):
    __tablename__ = 'crop'
    median_moe = 0
    parent = db.Column(db.String)
    children = db.Column(postgresql.ARRAY(db.String))
    internal_id = db.Column(db.Integer)
    crop = db.Column(db.String())
    crop_parent = db.Column(db.String())
    crop_name = db.Column(db.String())

    @classmethod
    def get_supported_levels(cls):
        return {"crop": ['all', 'lowest']}
示例#4
0
class Survey_Ygr(BasePoverty):
    __tablename__ = "survey_ygr"
    median_moe = 2

    year = db.Column(db.Integer(), primary_key=True)
    residence = db.Column(db.String(), primary_key=True)
    poverty_geo = db.Column(db.String(), primary_key=True)
    geo = column_property(PovertyXWalk.geo)
    gini = db.Column(db.Float)
    totpop = db.Column(db.Float)

    @classmethod
    def get_supported_levels(cls):
        base_levels = super(Survey_Ygr, cls).get_supported_levels()
        return dict(base_levels, **{RESIDENCE: [ALL, URBAN, RURAL]})
示例#5
0
class Survey_Ygg(BasePoverty):
    __tablename__ = "survey_ygg"
    median_moe = 2

    year = db.Column(db.Integer(), primary_key=True)
    gender = db.Column(db.String(), primary_key=True)
    poverty_geo = db.Column(db.String(), primary_key=True)
    geo = column_property(PovertyXWalk.geo)
    gini = db.Column(db.Float)
    totpop = db.Column(db.Float)

    @classmethod
    def get_supported_levels(cls):
        base_levels = super(Survey_Ygg, cls).get_supported_levels()
        return dict(base_levels, **{GENDER: [ALL, MALE, FEMALE]})
示例#6
0
class Survey_Yg(BasePoverty):
    __tablename__ = "survey_yg"
    median_moe = 1

    year = db.Column(db.Integer(), primary_key=True)
    poverty_geo = db.Column(db.String(), primary_key=True)
    geo = column_property(PovertyXWalk.geo)
    gini = db.Column(db.Float)
    totpop = db.Column(db.Float)
    url_name = column_property(
        select([Geo.url_name])
        .where(and_(poverty_geo == PovertyXWalk.poverty_geo, Geo.id == PovertyXWalk.geo)).limit(1)
    )
示例#7
0
class Rainfall(BaseClimate):
    __tablename__ = "rainfall"
    median_moe = 0
    year = db.Column(db.Integer, primary_key=True)
    geo = db.Column(db.String(), primary_key=True)

    start_year = db.Column(db.Integer)
    cropland_total_ha = db.Column(db.Float)
    rainfall_awa_mm = db.Column(db.Float)
    cropland_rainfallCVgt20pct_pct = db.Column(db.Float)
    cropland_rainfallCVgt20pct_ha = db.Column(db.Float)
    cropland_rainfallCVgt30pct_pct = db.Column(db.Float)
    cropland_rainfallCVgt30pct_ha = db.Column(db.Float)
示例#8
0
 def water_supply(cls):
     return db.Column(db.String(), primary_key=True)
示例#9
0
 def geo(cls):
     return db.Column(db.String(), db.ForeignKey(Geo.id), primary_key=True)
示例#10
0
 def crop(cls):
     return db.Column(db.String(), db.ForeignKey(Crop.id), primary_key=True)