diff options
author | Dennis Eriksen <d@ennis.no> | 2023-02-04 20:23:14 +0100 |
---|---|---|
committer | Dennis Eriksen <d@ennis.no> | 2023-02-04 20:23:21 +0100 |
commit | 3c9a54e0958e7c0341e470f508e5fbc6db920388 (patch) | |
tree | 3d9cb86bcb6454f6f615c5dc71388ac12c75c434 /scripts/tibber_prices.py | |
parent | adding variable to env.sample (diff) | |
download | energyscripts-3c9a54e0958e7c0341e470f508e5fbc6db920388.tar.gz |
sql-variables in common was stupid. put them where they are used
Diffstat (limited to 'scripts/tibber_prices.py')
-rw-r--r-- | scripts/tibber_prices.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/scripts/tibber_prices.py b/scripts/tibber_prices.py index 985a068..05db9a5 100644 --- a/scripts/tibber_prices.py +++ b/scripts/tibber_prices.py @@ -63,9 +63,24 @@ print("Got " + str(numdata) + " rows from Tibber") # prices prices = [] for item in data["data"]["viewer"]["homes"][0]["currentSubscription"]["priceInfo"]["today"]: - prices.append((item["startsAt"],item["total"],item["energy"],item["tax"],item["level"])) + prices.append(( + item["startsAt"], + item["total"], + item["energy"], + item["tax"], + item["level"])) for item in data["data"]["viewer"]["homes"][0]["currentSubscription"]["priceInfo"]["tomorrow"]: - prices.append((item["startsAt"],item["total"],item["energy"],item["tax"],item["level"])) - -common.dbi(common.sql[common.name], prices, verbose=True) + prices.append(( + item["startsAt"], + item["total"], + item["energy"], + item["tax"], + item["level"])) + +# SQL +sql = """ INSERT INTO tibber_prices + VALUES(%s, %s, %s, %s, %s) + ON CONFLICT (startsat) DO NOTHING""", + +common.dbi(sql, prices, verbose=True) |