Exemple #1
0
class DataSet(CRUDMixin, HelperMixin, db.Model):
    __tablename__ = 'dataset'

    id = db.Column(db.Integer, primary_key=True)
    filename = db.Column(db.VARCHAR(255))
    dataformat = db.Column(db.VARCHAR(10))
    title = db.Column(db.VARCHAR(50))
    rows = db.Column(db.Integer)
    columns = db.Column(db.Integer)
    description = db.Column(db.VARCHAR(200))
    uploadtime = db.Column(db.DateTime)
    status = db.Column(db.VARCHAR(10))

    def __init__(self,
                 filename=None,
                 dataformat=None,
                 title=None,
                 rows=None,
                 columns=None,
                 description=None,
                 uploadtime=None,
                 status=None):
        self.filename = filename
        self.dataformat = dataformat
        self.title = title
        self.rows = rows
        self.columns = columns
        self.description = description
        self.uploadtime = uploadtime
        self.status = status

    def __repr__(self):
        return "<DataSet(id='%s',filename='%s',dataformat='%s',title='%s',rows='%s',columns='%s',description='%s'," \
               "uploadtime='%s')>" % (str(self.id), self.filename, self.dataformat, self.title, str(self.rows),
                                      str(self.columns), self.description, str(self.uploadtime), self.status)
Exemple #2
0
class User(CRUDMixin, HelperMixin, db.Model):
    __tablename__ = 'user'

    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.VARCHAR(20))
    password = db.Column(db.VARCHAR(64))
    phone = db.Column(db.VARCHAR(15))
    gateway_id = db.Column(db.Integer,
                           db.ForeignKey('gateway.id',
                                         ondelete='CASCADE',
                                         onupdate='CASCADE'),
                           nullable=False)
    gateway = db.relation('Gateway', backref='user', lazy=False)
    created_at = db.Column(db.DateTime, default=utils.get_utc_now)

    def __init__(self,
                 username=None,
                 password=None,
                 gateway_id=None,
                 phone=None):
        self.username = username
        self.password = password
        self.gateway_id = gateway_id
        self.phone = phone

    def __repr__(self):
        return "<User(id='%s',username='******',password='******',gateway_id='%s',created_at='%s')>" % (
            str(self.id), self.username, self.password, self.gateway_id,
            str(self.created_at))
Exemple #3
0
class Gateway(CRUDMixin, HelperMixin, db.Model):
    __tablename__ = 'gateway'
    __table_args__ = {'extend_existing': True}

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.VARCHAR(30))
    url = db.Column(db.VARCHAR(30))
    address = db.Column(db.VARCHAR(50))
    latitude = db.Column(db.VARCHAR(20))
    longitude = db.Column(db.VARCHAR(20))
    status = db.Column(db.Boolean)
    created_at = db.Column(db.DateTime, default=utils.get_utc_now)

    def __init__(self,
                 name=None,
                 url=None,
                 address=None,
                 latitude=None,
                 longitude=None,
                 status=False):
        self.name = name
        self.url = url
        self.address = address
        self.latitude = latitude
        self.longitude = longitude
        self.status = status

    def __repr__(self):
        return "<Gateway(id='%s',name='%s',url='%s',address='%s',latitude='%s', longitude='%s', created_at='%s')>" % (
            str(self.id), self.name, self.url, self.address, self.latitude,
            self.longitude, str(self.created_at))
Exemple #4
0
class ActualWeather(CRUDMixin,HelperMixin,db.Model):
    __tablename__='actual_weather'

    id = db.Column(db.Integer,primary_key=True)
    publish_date = db.Column(db.DATE)
    created_at = db.Column(db.VARCHAR(100))
    region_id = db.Column(db.Integer,db.ForeignKey('region.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
    forecast_data = db.Column(db.DATE)
    order = db.Column(db.Integer)
    temperature = db.Column(db.FLOAT)
    humidity = db.Column(db.FLOAT)
    weather=db.Column(db.VARCHAR(45))
	
    def __init__(self,publish_date=None,created_at=None,region_id=None,forecast_data=None,order=None,temperature=None,humidity=None,weather=None):
        self.publish_date = publish_date
        self.created_at = created_at
        self.region_id = region_id
        self.forecast_data = forecast_data
        self.order = order
        self.temperature = temperature
        self.humidity = humidity
        self.weather = weather
		
    def __repr__(self):
        return "<ActualWeather(id='%s',publish_date='%s',created_at='%s',region_id='%s',forecast_data='%s',order='%s',temperature='%s',humidity='%s',weather='%s')>" % (
		        str(self.id),str(publish_date),str(created_at),str(self.region_id),str(self.forecast_data),str(self.order),str(self.temperature),str(self.humidity),self.weather)
Exemple #5
0
class DataModel(CRUDMixin,HelperMixin,db.Model):
    __tablename__='data_model'

    id = db.Column(db.Integer,primary_key=True)
    dataset_id = db.Column(db.Integer, db.ForeignKey('dataset.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
    name = db.Column(db.VARCHAR(100))
    algorithm_type = db.Column(db.VARCHAR(50))
    serialization = db.Column(db.Integer)
    description = db.Column(db.VARCHAR(200))
    created_at = db.Column(db.DateTime)
    status = db.Column(db.VARCHAR(1))
    dataset = db.relationship('DataSet', backref=db.backref('data_model', lazy='joined'), lazy='joined')
	
    def __init__(self,dataset_id=None,name=None,algorithm_type=None,serialization=None,description=None,created_at=None,status=None):
        self.dataset_id = dataset_id
	self.name = name
        self.algorithm_type = algorithm_type
        self.serialization = serialization
        self.description = description
        self.created_at = created_at
        self.status = status
		
    def __repr__(self):
        return "<DataModel(id='%s',dataset_id='%s',name='%s',algorithm_type='%s',serialization='%s',description='%s',created_at='%s',status='%s')>" % (
		        str(self.id),str(dataset_id),self.name,self.algorithm_type,self.serialization,self.description,str(self.created_at),str(self.status))
Exemple #6
0
class Test(CRUDMixin, HelperMixin,db.Model):
    __tablename__='test'
    
    id = db.Column(db.Integer,primary_key=True)
    name =  db.Column(db.VARCHAR(20))
    age = db.Column(db.VARCHAR(20))
    
    def __init__(self,name=None ,age=None):
        self.name = name
        self.age = age

    def __repr__(self):
        return "<Test(id='%s',name='%s',age='%s')>" % (str(self.id),self.name,self.age)
Exemple #7
0
class HisWeather(CRUDMixin, HelperMixin, db.Model):
    __tablename__ = 'his_weather'

    id = db.Column(db.Integer, primary_key=True)
    publish_date = db.Column(db.DATE)
    created_at = db.Column(db.DateTime, default=utils.get_utc_now)
    region_id = db.Column(db.Integer,
                          db.ForeignKey('gateway.id',
                                        ondelete='CASCADE',
                                        onupdate='CASCADE'),
                          nullable=False)
    temperature = db.Column(db.FLOAT)
    humidity = db.Column(db.FLOAT)
    weather = db.Column(db.VARCHAR(45))

    def __init__(self,
                 publish_date=None,
                 region_id=None,
                 temperature=None,
                 humidity=None,
                 weather=None):
        self.publish_date = publish_date
        # self.created_at = created_at
        self.region_id = region_id
        self.temperature = temperature
        self.humidity = humidity
        self.weather = weather

    def __repr__(self):
        return "<HisWeather(id='%s',publish_date='%s',created_at='%s',region_id='%s',temperature='%s',humidity='%s'," \
               "weather='%s')>" % (str(self.id), str(self.publish_date), str(self.created_at), str(self.region_id),
                                   str(self.temperature), str(self.humidity), self.weather)