From ac991dabfb781dfa689b094171681ded470043ec Mon Sep 17 00:00:00 2001 From: reedts Date: Thu, 17 May 2018 15:28:36 +0200 Subject: [PATCH] Fixed bug in database backend --- pywatts/fetchdata.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pywatts/fetchdata.py b/pywatts/fetchdata.py index a75f7c0..95ac34f 100644 --- a/pywatts/fetchdata.py +++ b/pywatts/fetchdata.py @@ -33,8 +33,11 @@ def store_data(result_list): db.create_tables([WeatherStation, Result]) for result in result_list: + if result.errors: + continue + if WeatherStation.select().where(WeatherStation.id == result.station_info['location']).exists(): - print("Data for station %s already in database. Skipping." % result.station_info.location) + print("Data for station %s already in database. Skipping." % result.station_info['location']) continue station = WeatherStation.create( @@ -53,3 +56,5 @@ def store_data(result_list): temperature=result.outputs['tamb'], wind_speed=result.outputs['wspd'] ) + + db.close()