diff options
author | Dennis Eriksen <d@ennis.no> | 2023-02-04 21:53:54 +0100 |
---|---|---|
committer | Dennis Eriksen <d@ennis.no> | 2023-02-04 21:53:54 +0100 |
commit | cc137038fa8c1db5e24a2ba103c7dbee79affa95 (patch) | |
tree | 9f36ab0847cc99f10940859364b1db813376cd91 /scripts/yr.py | |
parent | sql-variables in common was stupid. put them where they are used (diff) | |
download | energyscripts-cc137038fa8c1db5e24a2ba103c7dbee79affa95.tar.gz |
adding location and rooms
updating yr to add location
added coule tables to schema I forgot
Diffstat (limited to 'scripts/yr.py')
-rw-r--r-- | scripts/yr.py | 16 |
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, |