def contacts(): query = ( """SELECT concat(mentors.first_name, ' ', mentors.last_name), schools.name FROM mentors INNER JOIN schools ON mentors.city = schools.city ORDER BY schools.name""") asked_parameters = database_manager(query) return render_template('results.html', asked_parameters=asked_parameters)
def mentors_by_country(): query = ("""SELECT schools.country, COUNT(mentors.first_name) FROM mentors INNER JOIN schools ON mentors.city = schools.city GROUP BY schools.country ORDER BY schools.country""") asked_parameters = database_manager(query) return render_template('results.html', asked_parameters=asked_parameters)
def all_school(): query = ( """SELECT concat(mentors.first_name, ' ', mentors.last_name), schools.name, schools.country FROM mentors RIGHT JOIN schools ON mentors.city = schools.city ORDER BY mentors.id""") asked_parameters = database_manager(query) return render_template('results.html', asked_parameters=asked_parameters)
def applicants_and_mentors(): query = ( """SELECT applicants.first_name, applicants.application_code, mentors.first_name, mentors.last_name FROM applicants LEFT JOIN applicants_mentors ON applicants.id = applicants_mentors.applicant_id LEFT JOIN mentors ON mentors.id = applicants_mentors.mentor_id""") asked_parameters = database_manager(query) return render_template('results.html', asked_parameters=asked_parameters)
def applicants(): query = ( """SELECT applicants.first_name, applicants.application_code, applicants_mentors.creation_date FROM applicants INNER JOIN applicants_mentors ON applicants.id = applicants_mentors.applicant_id WHERE applicants_mentors.creation_date > '2016-01-01' ORDER BY applicants_mentors.creation_date DESC""") asked_parameters = database_manager(query) return render_template('results.html', asked_parameters=asked_parameters)
drive_actuator(room, constants.actuator_hot, constants.power_on) else: drive_actuator(room, constants.actuator_hot, constants.power_off) # If it is a hot season, cold actuators must be used elif season == 'hot': drive_actuator(room, constants.actuator_hot, constants.power_off) if temperature > requested_temperature: drive_actuator(room, constants.actuator_cold, constants.power_on) else: drive_actuator(room, constants.actuator_cold, constants.power_off) # Start mqtt connection mqtt_manager = connection_manager() mqtt_manager.mqtt_connect(on_connect, on_message) # Define db manager db_manager = database_manager() while True: # Get last temperatures received through mqtt last_temperatures = db_manager.get_last_temperatures() # Get configuration from the db #configuration = {'rooms_settings': [{'room': 'stanzetta', 'room_name': 'stanzetta', 'mode': 'm/p/f', 'info': {'temp': 25, 'weekend': 0}, 'season': 'hot/cold'}], 'backup_config': 'none'} configuration = db_manager.get_configuration() # Manage only rooms from which temperatures are received since the last power-on #for entry in last_temperatures: # temp_room = entry['room'] # temp_temperature = entry['temperature'] # room_settings = find_room_in_list(temp_room, configuration['rooms_settings']) # # Manage every room of the configuration