From 8ebc806a48dd4150c063ae7e537945a9c97af46e Mon Sep 17 00:00:00 2001 From: Dougie Lawson Date: Mon, 22 Jan 2018 21:02:50 +0000 Subject: [PATCH] Update database.py Solve the data trunctation on insert problem by rounding every value out to match the database column definition. --- database.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/database.py b/database.py index 9ebf02d..fb0a626 100755 --- a/database.py +++ b/database.py @@ -115,15 +115,15 @@ def is_none(self, val): return val if val != None else "NULL" def insert(self, ambient_temperature, ground_temperature, air_quality, air_pressure, humidity, wind_direction, wind_speed, wind_gust_speed, rainfall, created = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")): - params = ( ambient_temperature, - ground_temperature, - air_quality, - air_pressure, - humidity, - wind_direction, - wind_speed, - wind_gust_speed, - rainfall, + params = ( str(round(ambient_temperature,2)), + str(round(ground_temperature,2)), + str(round(air_quality,2)), + str(round(air_pressure,2)), + str(round(humidity,2)), + str(round(wind_direction,2)), + str(round(wind_speed,2)), + str(round(wind_gust_speed,2)), + str(round(rainfall,2)), created ) print(self.insert_template % params) self.db.execute(self.insert_template, params)