def get_by_search(start, end):
        # Init
        returnValue = []
        conn = ConnectionService.get_connection()
        cur = conn.cursor()

        # Execution
        logging.debug("Starting select")
        cur.execute(
            'Select * from tbl_historic_pressure where fld_start_time>=? and fld_end_time<=?',
            (
                start,
                end,
            ))

        # Formatting of return data
        logging.debug("Formatting query data to objects")
        for id, start, end, value in cur:
            temp = HistoricPressureModel(id, start, end, value)
            returnValue.append(temp)

        # Clean and return
        logging.debug("Closing connection")
        conn.close()

        return returnValue
    def get_average_by_range(start, end):
        # Init
        returnValue = None
        conn = ConnectionService.get_connection()
        cur = conn.cursor()

        # Execution
        logging.debug("Starting select")
        cur.execute(
            'Select AVG(fld_average) from tbl_historic_pressure where fld_start_time>=? and fld_end_time<=?',
            (
                start,
                end,
            ))

        # Formatting of return data
        logging.debug("Formatting query data to objects")
        for c in cur:
            returnValue = c[0]  # Average

        # Clean and return
        logging.debug("Closing connection")
        conn.close()

        return returnValue
    def delete_all():
        # Init
        returnValue = True
        conn = ConnectionService.get_connection()
        cur = conn.cursor()

        # Execution
        logging.debug("Starting delete")
        cur.execute("Delete from tbl_historic_pressure")

        logging.debug("Committing changes")
        conn.commit()

        # Clean and return
        logging.debug("Closing connection")
        conn.close()

        return returnValue
	def delete_by_range(start,end):
		# Init
		returnValue = True
		conn = ConnectionService.get_connection()
		cur = conn.cursor()

		# Execution
		logging.debug("Starting delete")
		cur.execute('Delete from tbl_historic_humidity where fld_start_time>=? and fld_end_time<=?', (start,end,))

		logging.debug("Committing changes")
		conn.commit()

		# Clean and return
		logging.debug("Closing connection")
		conn.close()

		return returnValue
	def get_by_id(id):
		# Init
		returnValue = None
		conn = ConnectionService.get_connection()
		cur = conn.cursor()

		# Execution
		logging.debug("Starting select")
		cur.execute('Select * from tbl_historic_humidity where fld_pk_id=?', (id,))

		# Formatting of return data
		logging.debug("Formatting query data to objects")
		for id,start, end, value in cur:
			returnValue = HistoricHumidityModel(id, start, end, value)

		# Clean and return
		logging.debug("Closing connection")
		conn.close()
		
		return returnValue
	def get_newest():
		# Init
		returnValue = None
		conn = ConnectionService.get_connection()
		cur = conn.cursor()

		# Execution
		logging.debug("Starting select")
		cur.execute('Select * from tbl_historic_humidity order by fld_end_time desc limit 1')

		# Formatting of return data
		logging.debug("Formatting query data to objects")
		for id,start, end, value in cur:
			returnValue = HistoricHumidityModel(id,start, end, value)

		# Clean and return
		logging.debug("Closing connection")
		conn.close()

		return returnValue
	def get_average():
		# Init
		returnValue = None
		conn = ConnectionService.get_connection()
		cur = conn.cursor()

		# Execution
		logging.debug("Starting select")
		cur.execute('Select AVG(fld_average) from tbl_historic_humidity')

		# Formatting of return data
		logging.debug("Formatting query data to objects")
		for c in cur:
			returnValue = c[0] #Average

		# Clean and return
		logging.debug("Closing connection")
		conn.close()

		return returnValue
예제 #8
0
	def get_newest():
		# Init
		returnValue = None
		conn = ConnectionService.get_connection()
		cur = conn.cursor()

		# Execution
		logging.debug("Starting select")
		cur.execute('Select * from tbl_recent_pressure order by fld_time desc limit 1')

		# Formatting of return data
		logging.debug("Formatting query data to objects")
		for id, time, value in cur:
			returnValue = RecentPressureModel(id, time, value)

		# Clean and return
		logging.debug("Closing connection")
		conn.close()

		return returnValue
예제 #9
0
	def get_by_id(id):
		# Init
		returnValue = None
		conn = ConnectionService.get_connection()
		cur = conn.cursor()

		# Execution
		logging.debug("Starting select")
		cur.execute('Select * from tbl_recent_pressure where fld_pk_id=?', (id,))

		# Formatting of return data
		logging.debug("Formatting query data to objects")
		for id, time, value in cur:
			returnValue = RecentPressureModel(id, time, value)

		# Clean and return
		logging.debug("Closing connection")
		conn.close()

		return returnValue
	def get_all():
		# Init
		returnValue = []
		conn = ConnectionService.get_connection()
		cur = conn.cursor()

		# Execution
		logging.debug("Starting select")
		cur.execute('Select * from tbl_historic_humidity')

		# Formatting of return data
		logging.debug("Formatting query data to objects")
		for id, start, end, value in cur:
			temp = HistoricHumidityModel(id,start, end, value)
			returnValue.append(temp)

		# Clean and return
		logging.debug("Closing connection")
		conn.close()

		return returnValue
    def get_all():
        # Init
        returnValue = []
        conn = ConnectionService.get_connection()
        cur = conn.cursor()

        # Execution
        logging.debug("Starting select")
        cur.execute('Select * from tbl_recent_temperature')

        # Formatting of return data
        logging.debug("Formatting query data to objects")
        for id, time, value in cur:
            temp = RecentTemperatureModel(id, time, value)
            returnValue.append(temp)

        # Clean and return
        logging.debug("Closing connection")
        conn.close()

        return returnValue
예제 #12
0
	def post(self):
		# Init
		conn = ConnectionService.get_connection()
		cur = conn.cursor()

		# Execution
		logging.debug("Starting insert")
		cur.execute(
			'Insert into tbl_recent_pressure(fld_time,fld_value) values (UTC_TIMESTAMP(),?)', (self.value,))

		logging.debug("Committing changes")
		conn.commit()

		# Update this Object with
		self.id = cur.lastrowid
		self.time = RecentPressureModel.get_by_id(self.id).time
		logging.debug("Generated item has id: " + str(self.id))

		# Clean and return
		logging.debug("Closing connection")
		conn.close()

		return self.id