Fixed bug in database backend
This commit is contained in:
parent
1146a9bdde
commit
ac991dabfb
1 changed files with 6 additions and 1 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue