diff options
Diffstat (limited to '')
-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) |