From 3c9a54e0958e7c0341e470f508e5fbc6db920388 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Sat, 4 Feb 2023 20:23:14 +0100 Subject: sql-variables in common was stupid. put them where they are used --- scripts/entsoe.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'scripts/entsoe.py') diff --git a/scripts/entsoe.py b/scripts/entsoe.py index 2a7d6f7..4a136af 100644 --- a/scripts/entsoe.py +++ b/scripts/entsoe.py @@ -80,7 +80,18 @@ for area in areas: time = str(cettime + timedelta(hours = int(item["position"]) - 1)) # append values - values.append((time, area["name"], item["price.amount"])) + values.append(( + time, + area["name"], + item["price.amount"])) + print("Got " + str(items) + " records") -common.dbi(common.sql[jobname], values, verbose=True) +# SQL +sql = """ INSERT INTO entsoe + VALUES(%s, %s, %s) + ON CONFLICT (starttime, zone) DO NOTHING""" + + + +common.dbi(sql, values, verbose=True) -- cgit v1.2.3