diff options
author | Dennis Eriksen <d@ennis.no> | 2023-02-04 14:18:18 +0100 |
---|---|---|
committer | Dennis Eriksen <d@ennis.no> | 2023-02-04 14:18:18 +0100 |
commit | eb5e90aded9a7259ddecc94d9244393fa5abd2e6 (patch) | |
tree | 8e166a3bec6435c1490cff04cd704ae847b47eba /scripts/entsoe.py | |
parent | queue sleep as variable (diff) | |
download | energyscripts-eb5e90aded9a7259ddecc94d9244393fa5abd2e6.tar.gz |
moving some variables around
Diffstat (limited to 'scripts/entsoe.py')
-rw-r--r-- | scripts/entsoe.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/scripts/entsoe.py b/scripts/entsoe.py index 85785dc..2a7d6f7 100644 --- a/scripts/entsoe.py +++ b/scripts/entsoe.py @@ -10,7 +10,7 @@ import xmltodict from tzlocal import get_localzone from dateutil import tz -from common import dbi +import common # variables @@ -29,16 +29,14 @@ apiKey = os.environ['el_entsoe_token'] # https://transparency.entsoe.eu/content/static_content/Static%20content/web%20api/Guide.html apiUrl = "https://transparency.entsoe.eu/api?securityToken=" + apiKey -pg_db = os.environ['el_pg_db'] -pg_host = os.environ['el_pg_host'] -pg_table = "entsoe" - startTime = datetime.now(get_localzone()) - timedelta(days = 7) startTime = startTime.strftime('%Y%m%d') endTime = datetime.now(get_localzone()) + timedelta(days = 1) endTime = endTime.strftime('%Y%m%d') +jobname = os.path.splitext(os.path.basename(__file__))[0] + # https://transparency.entsoe.eu/content/static_content/Static%20content/web%20api/Guide.html#_areas areas = [ {"name": "NO-0", "code": "10YNO-0--------C"}, {"name": "NO-1", "code": "10YNO-1--------2"}, @@ -85,4 +83,4 @@ for area in areas: values.append((time, area["name"], item["price.amount"])) print("Got " + str(items) + " records") -dbi("INSERT INTO " + pg_table + " VALUES(%s,%s,%s) ON CONFLICT (starttime, zone) DO NOTHING", values, verbose=True) +common.dbi(common.sql[jobname], values, verbose=True) |