aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/yr.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/yr.py')
-rw-r--r--scripts/yr.py16
1 files changed, 13 insertions, 3 deletions
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,