# coding: utf-8 from sqlalchemy import Column, Date, DateTime, Float, Index, Integer, String, Text from sqlalchemy.schema import FetchedValue from flask_sqlalchemy import SQLAlchemy # db = SQLAlchemy() #與當前項目相關的模型文件,即所有的實體類在此編寫 from manage import db class User(db.Model): __tablename__ = 'user' userID = db.Column(db.Integer, primary_key=True) firstname = db.Column(db.String(30), nullable=False) lastname = db.Column(db.String(30), nullable=False) mail = db.Column(db.String(50), nullable=False) phone = db.Column(db.String(20), nullable=False) username = db.Column(db.String(30), nullable=False, unique=True) password = db.Column(db.String(40), nullable=False) status = db.Column(db.Integer, nullable=False, info='0:admin;1:new;9:disable') class LiquidTank(db.Model): __tablename__ = 'liquid_tank' sn = db.Column(db.Integer, primary_key=True) datetime = db.Column(db.DateTime, nullable=False) fitolab = db.Column(db.Integer, nullable=False, default=1) tk1_duration1 = db.Column(db.Text, nullable=True) tk1_start1 = db.Column(db.Text, nullable=True) tk1_end1 = db.Column(db.Text, nullable=True) tk1_duration2 = db.Column(db.Text, nullable=True) tk1_start2 = db.Column(db.Text, nullable=True) tk1_end2 = db.Column(db.Text, nullable=True) tk1_duration3 = db.Column(db.Text, nullable=True) tk1_start3 = db.Column(db.Text, nullable=True) tk1_end3 = db.Column(db.Text, nullable=True) tk2_duration1 = db.Column(db.Text, nullable=True) tk2_start1 = db.Column(db.Text, nullable=True) tk2_end1 = db.Column(db.Text, nullable=True) tk2_duration2 = db.Column(db.Text, nullable=True) tk2_start2 = db.Column(db.Text, nullable=True) tk2_end2 = db.Column(db.Text, nullable=True) tk2_duration3 = db.Column(db.Text, nullable=True) tk2_start3 = db.Column(db.Text, nullable=True) tk2_end3 = db.Column(db.Text, nullable=True) class LightControl(db.Model): __tablename__ = 'light_control' sn = db.Column(db.Integer, primary_key=True) datetime = db.Column(db.DateTime, nullable=True) fitolab = db.Column(db.Integer, nullable=False, default=1) l_kind = db.Column(db.Text, nullable=False) l_start = db.Column(db.Text, nullable=True) l_end = db.Column(db.Text, nullable=True) l_r = db.Column(db.Integer, nullable=True) l_g = db.Column(db.Integer, nullable=True) l_b = db.Column(db.Integer, nullable=True) l_bright_auto = db.Column(db.Integer, nullable=False, info='0:off;1:on') l_bright_vol = db.Column(db.Integer, nullable=False) class MusicControl(db.Model): __tablename__ = 'music_control' sn = db.Column(db.Integer, primary_key=True) datetime = db.Column(db.DateTime, nullable=True) fitolab = db.Column(db.Integer, nullable=False, default=1) m_vol = db.Column(db.Text, nullable=False, default='40') m_playlist = db.Column(db.Integer, nullable=True) m_start = db.Column(db.Text, nullable=True) m_end = db.Column(db.Text, nullable=True) class VibrationControl(db.Model): __tablename__ = 'vibration_control' sn = db.Column(db.Integer, primary_key=True) datetime = db.Column(db.DateTime, nullable=False) fitolab = db.Column(db.Integer, nullable=False, default=1) v_power = db.Column(db.Text, nullable=False, default='40') v_vol = db.Column(db.Text, nullable=False) v_start = db.Column(db.Text, nullable=False) v_end = db.Column(db.Text, nullable=False) class CameraControl(db.Model): __tablename__ = 'camera_control' sn = db.Column(db.Integer, primary_key=True) datetime = db.Column(db.DateTime, nullable=False) fitolab = db.Column(db.Integer, nullable=False, default=1) c_status = db.Column(db.Integer, nullable=False, info='0:off;1:on') c_piriodicity = db.Column(db.Text, nullable=False) c_live_stream = db.Column(db.Text, nullable=False) class Gallery(db.Model): __tablename__ = 'gallery' sn = db.Column(db.Integer, primary_key=True) datetime = db.Column(db.DateTime, nullable=False) fitolab = db.Column(db.Integer, nullable=False, default=1) img = db.Column(db.Text, nullable=False) class RootSystem(db.Model): __tablename__ = 'root_system' sn = db.Column(db.Integer, primary_key=True) datetime = db.Column(db.DateTime, nullable=False) fitolab = db.Column(db.Integer, nullable=False, default=1) tem_tem1 = db.Column(db.Text, nullable=True) tem_start1 = db.Column(db.Text, nullable=True) tem_end1 = db.Column(db.Text, nullable=True) tem_tem2 = db.Column(db.Text, nullable=True) tem_start2 = db.Column(db.Text, nullable=True) tem_end2 = db.Column(db.Text, nullable=True) tem_tem3 = db.Column(db.Text, nullable=True) tem_start3 = db.Column(db.Text, nullable=True) tem_end3 = db.Column(db.Text, nullable=True) l_start1 = db.Column(db.Text, nullable=True) l_end1 = db.Column(db.Text, nullable=True) l_start2 = db.Column(db.Text, nullable=True) l_end2 = db.Column(db.Text, nullable=True) l_start3 = db.Column(db.Text, nullable=True) l_end3 = db.Column(db.Text, nullable=True) l_r = db.Column(db.Integer, nullable=True) l_g = db.Column(db.Integer, nullable=True) l_b = db.Column(db.Integer, nullable=True) l_bright_auto = db.Column(db.Integer, nullable=True, info='0:off;1:on') l_bright_vol = db.Column(db.Integer, nullable=True) fan_status = db.Column(db.Integer, nullable=True, info='0:off;1:on') fan_periodicity = db.Column(db.Text, nullable=True) fan_duration = db.Column(db.Text, nullable=True) fan_speed = db.Column(db.Text, nullable=True) humidity = db.Column(db.Text, nullable=True) class StemSystem(db.Model): __tablename__ = 'stem_system' sn = db.Column(db.Integer, primary_key=True) datetime = db.Column(db.DateTime, nullable=False) fitolab = db.Column(db.Integer, nullable=False, default=1) tem_tem1 = db.Column(db.Text, nullable=True) tem_start1 = db.Column(db.Text, nullable=True) tem_end1 = db.Column(db.Text, nullable=True) tem_tem2 = db.Column(db.Text, nullable=True) tem_start2 = db.Column(db.Text, nullable=True) tem_end2 = db.Column(db.Text, nullable=True) tem_tem3 = db.Column(db.Text, nullable=True) tem_start3 = db.Column(db.Text, nullable=True) tem_end3 = db.Column(db.Text, nullable=True) l_start1 = db.Column(db.Text, nullable=True) l_end1 = db.Column(db.Text, nullable=True) l_start2 = db.Column(db.Text, nullable=True) l_end2 = db.Column(db.Text, nullable=True) l_start3 = db.Column(db.Text, nullable=True) l_end3= db.Column(db.Text, nullable=True) l_r = db.Column(db.Integer, nullable=True) l_g = db.Column(db.Integer, nullable=True) l_b = db.Column(db.Integer, nullable=True) l_bright_auto = db.Column(db.Integer, nullable=True, info='0:off;1:on') l_bright_vol = db.Column(db.Integer, nullable=True) c_status = db.Column(db.Integer, nullable=True, info='0:off;1:on') c_duration = db.Column(db.Text, nullable=True) t_n_s_tem1 = db.Column(db.Text, nullable=True) t_n_s_start1 = db.Column(db.Text, nullable=True) t_n_s_end1 = db.Column(db.Text, nullable=True) t_n_s_tem2 = db.Column(db.Text, nullable=True) t_n_s_start2 = db.Column(db.Text, nullable=True) t_n_s_end2 = db.Column(db.Text, nullable=True) t_n_s_tem3 = db.Column(db.Text, nullable=True) t_n_s_start3 = db.Column(db.Text, nullable=True) t_n_s_end3 = db.Column(db.Text, nullable=True) m_vol = db.Column(db.Text, nullable=True, default='40') m_playlist1 = db.Column(db.Text, nullable=True) m_start1 = db.Column(db.Text, nullable=True) m_end1 = db.Column(db.Text, nullable=True) m_playlist2 = db.Column(db.Text, nullable=True) m_start2 = db.Column(db.Text, nullable=True) m_end2 = db.Column(db.Text, nullable=True) m_playlist3 = db.Column(db.Text, nullable=True) m_start3 = db.Column(db.Text, nullable=True) m_end3 = db.Column(db.Text, nullable=True) u_s_status = db.Column(db.Integer, nullable=True, info='0:off;1:on') u_s_vol = db.Column(db.Text, nullable=True) u_s_start1 = db.Column(db.Text, nullable=True) u_s_end1 = db.Column(db.Text, nullable=True) u_s_start2 = db.Column(db.Text, nullable=True) u_s_end2 = db.Column(db.Text, nullable=True) u_s_start3 = db.Column(db.Text, nullable=True) u_s_end3 = db.Column(db.Text, nullable=True) v_power = db.Column(db.Text, nullable=True, default='40') v_vol1 = db.Column(db.Text, nullable=True) v_start1 = db.Column(db.Text, nullable=True) v_end1 = db.Column(db.Text, nullable=True) v_vol2 = db.Column(db.Text, nullable=True) v_start2 = db.Column(db.Text, nullable=True) v_end2 = db.Column(db.Text, nullable=True) v_vol3 = db.Column(db.Text, nullable=True) v_start3 = db.Column(db.Text, nullable=True) v_end3 = db.Column(db.Text, nullable=True) w_vol1 = db.Column(db.Text, nullable=True) w_start1 = db.Column(db.Text, nullable=True) w_end1 = db.Column(db.Text, nullable=True) w_vol2 = db.Column(db.Text, nullable=True) w_start2 = db.Column(db.Text, nullable=True) w_end2 = db.Column(db.Text, nullable=True) w_vol3 = db.Column(db.Text, nullable=True) w_start3 = db.Column(db.Text, nullable=True) w_end3 = db.Column(db.Text, nullable=True) rh = db.Column(db.Text, nullable=True) class Fitolab1Sensor(db.Model): __tablename__ = 'fitolab1_sensor' sn = db.Column(db.Integer, primary_key=True) datetime = db.Column(db.DateTime, nullable=False) s_humidity = db.Column(db.Float, nullable=True) s_wind_flow = db.Column(db.Float, nullable=True) s_temp = db.Column(db.Float, nullable=True) s_near_stem1 = db.Column(db.Float, nullable=True) s_near_stem2 = db.Column(db.Float, nullable=True) s_air_tem1 = db.Column(db.Float, nullable=True) s_air_tem2 = db.Column(db.Float, nullable=True) s_orp = db.Column(db.Float, nullable=True) s_wgt = db.Column(db.Float, nullable=True) s_wgt_sensor1 = db.Column(db.Float, nullable=True) s_wgt_sensor2 = db.Column(db.Float, nullable=True) s_water_frequency = db.Column(db.Float, nullable=True) s_h2 = db.Column(db.Float, nullable=True) s_n2 = db.Column(db.Float, nullable=True) s_c2h4 = db.Column(db.Float, nullable=True) s_o3 = db.Column(db.Float, nullable=True) s_o2 = db.Column(db.Float, nullable=True) s_co2 = db.Column(db.Float, nullable=True) s_chlorophyll = db.Column(db.Float, nullable=True) s_leaf = db.Column(db.Text, nullable=True) r_humidity = db.Column(db.Float, nullable=True) r_air_temp = db.Column(db.Float, nullable=True) r_water_temp = db.Column(db.Float, nullable=True) r_orp = db.Column(db.Float, nullable=True) r_ec = db.Column(db.Float, nullable=True) r_do = db.Column(db.Float, nullable=True) r_ed = db.Column(db.Float, nullable=True) r_wind_flow = db.Column(db.Float, nullable=True) r_water_level = db.Column(db.Text, nullable=True) r_fluorine = db.Column(db.Float, nullable=True) r_ph = db.Column(db.Float, nullable=True) r_turbidity = db.Column(db.Float, nullable=True) r_nh4 = db.Column(db.Float, nullable=True) r_co2 = db.Column(db.Float, nullable=True) r_no3 = db.Column(db.Float, nullable=True) r_no2 = db.Column(db.Float, nullable=True) db.create_all()