From cc137038fa8c1db5e24a2ba103c7dbee79affa95 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Sat, 4 Feb 2023 21:53:54 +0100 Subject: adding location and rooms updating yr to add location added coule tables to schema I forgot --- scripts/yr.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'scripts/yr.py') diff --git a/scripts/yr.py b/scripts/yr.py index f6b654c..243f531 100644 --- a/scripts/yr.py +++ b/scripts/yr.py @@ -7,6 +7,7 @@ import requests import common +location = int(os.environ['el_location']) lat = str(os.environ['el_yr_lat']) lon = str(os.environ['el_yr_lon']) @@ -42,6 +43,7 @@ for item in data["properties"]["timeseries"]: details = item["data"]["instant"]["details"] values.append(( item["time"], + location, details["air_temperature"], details["air_pressure_at_sea_level"], details["cloud_area_fraction"], @@ -50,9 +52,17 @@ for item in data["properties"]["timeseries"]: details["wind_speed"])) # SQL -sql = """ INSERT INTO yr - VALUES(%s, %s, %s, %s, %s, %s, %s) - ON CONFLICT (time) DO UPDATE SET +sql = """ INSERT INTO yr ( + time, + location, + air_temperature, + air_pressure_at_sea_level, + cloud_area_fraction, + relative_humidity, + wind_from_direction, + wind_speed) + VALUES(%s, %s, %s, %s, %s, %s, %s, %s) + ON CONFLICT (time, location) DO UPDATE SET air_temperature=EXCLUDED.air_temperature, air_pressure_at_sea_level=EXCLUDED.air_pressure_at_sea_level, cloud_area_fraction=EXCLUDED.cloud_area_fraction, -- cgit v1.2.3