diff options
Diffstat (limited to 'scripts/tibber_prices.py')
-rw-r--r-- | scripts/tibber_prices.py | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/scripts/tibber_prices.py b/scripts/tibber_prices.py index a2e9dda..985a068 100644 --- a/scripts/tibber_prices.py +++ b/scripts/tibber_prices.py @@ -8,17 +8,13 @@ from datetime import timedelta from tzlocal import get_localzone import requests -from common import dbi +import common # variables apiKey = os.environ['el_tibber_token'] apiUrl = "https://api.tibber.com/v1-beta/gql" -pg_db = os.environ['el_pg_db'] -pg_host = os.environ['el_pg_host'] -pg_table = "tibber_prices" - startTime = datetime.now(get_localzone()) - timedelta(days = 1) startTime = startTime.isoformat('T') @@ -72,5 +68,4 @@ for item in data["data"]["viewer"]["homes"][0]["currentSubscription"]["priceInfo for item in data["data"]["viewer"]["homes"][0]["currentSubscription"]["priceInfo"]["tomorrow"]: prices.append((item["startsAt"],item["total"],item["energy"],item["tax"],item["level"])) - -dbi("INSERT INTO " + pg_table + " VALUES(%s,%s,%s,%s,%s) ON CONFLICT (startsat) DO NOTHING", prices, verbose=True) +common.dbi(common.sql[common.name], prices, verbose=True) |