Exemplo n.º 1
0
def save_db_outdoor(Outdoor):
    with app.app_context():
        db = get_db()
        db.execute('INSERT INTO outdoor(update_time,temperature,humidity,radiation,co2,wind_direction,wind_speed,rain_snow,atmosphere)\
                   VALUES(?,?,?,?,?,?,?,?,?)',
                   [Outdoor.get_update_time(), Outdoor.get_temperature(), Outdoor.get_humidity(), Outdoor.get_radiation(),
                    Outdoor.get_co_2(),
                    Outdoor.get_wind_direction(), \
                    Outdoor.get_wind_speed(), Outdoor.get_rain(), Outdoor.get_atmosphere()])
        db.commit()
        db.close()
    print 'outdoor save success'
Exemplo n.º 2
0
def save_db_outdoor(Outdoor):
    with app.app_context():
        db = get_db()
        db.execute('INSERT INTO outdoor(update_time,temperature,humidity,radiation,co2,wind_direction,wind_speed,rain_snow,atmosphere)\
                   VALUES(?,?,?,?,?,?,?,?,?)',
                   [Outdoor.get_update_time(), Outdoor.get_temperature(), Outdoor.get_humidity(), Outdoor.get_radiation(),
                    Outdoor.get_co_2(),
                    Outdoor.get_wind_direction(),
                    Outdoor.get_wind_speed(), Outdoor.get_rain(), Outdoor.get_atmosphere()])
        db.commit()
        db.close()
    print 'outdoor save success'
Exemplo n.º 3
0
def save_db_outdoor(Outdoor):
    with app.app_context():
        db = get_db()
        db.cursor().execute(
            'insert into outdoor(update_time,temperature,humidity,radiation,co2,wind_direction,wind_speed,rain_snow,atmosphere)\
                   values(%s,%s,%s,%s,%s,%s,%s,%s,%s)', [
                Outdoor.get_update_time(),
                Outdoor.get_temperature(),
                Outdoor.get_humidity(),
                Outdoor.get_radiation(),
                Outdoor.get_co_2(),
                Outdoor.get_wind_direction(),
                Outdoor.get_wind_speed(),
                Outdoor.get_rain(),
                Outdoor.get_atmosphere()
            ])
        db.commit()
    print 'outdoor save success'
Exemplo n.º 4
0
#     '''%(row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[8],row[9],row[10],row[11],row[12],row[13],row[14],row[15])

if __name__ == '__main__':
    print 'test start'
    indoor = Indoor('2')
    outdoor = Outdoor()
    control = Control()
    # print get_db_actutor_current_state()
    #d='''{"outdoor_radiation": "true","start": "2016-06-17",
    #"stop": "2016-08-22"}'''
    #print handle_query_condition(d)
    outdoor.get_weather_from_api()
    #save_db_outdoor(outdoor)
    # print outdoor.build_json()
    # temperature, humidity, radiation, co2, wind_direction, wind_speed, rain_snow,atmosphere
    print outdoor.get_wind_direction()
    outdoor.set_wind_direction_number()
    print outdoor.get_wind_direction()
    # print outdoor.get_rain()
    with app.app_context():
        db = get_db()
        db.cursor().execute(
            'insert into outdoor(wind_direction)\
                   values(%s)', [outdoor.get_wind_direction()])
        db.commit()
    # query = 'select * from control_state where id=(select max(id) from control_state)'
    # query_db(query)
    # get_db_control_state(control)
    # print control.build_json()
    # get_db_indoor(indoor)
    # print indoor.build_json()