From eb5e90aded9a7259ddecc94d9244393fa5abd2e6 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Sat, 4 Feb 2023 14:18:18 +0100 Subject: moving some variables around --- scripts/elvia.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'scripts/elvia.py') diff --git a/scripts/elvia.py b/scripts/elvia.py index 6e4bc9f..2248238 100644 --- a/scripts/elvia.py +++ b/scripts/elvia.py @@ -8,13 +8,11 @@ from datetime import timedelta from tzlocal import get_localzone import requests -from common import dbi +import common apiKey = os.environ['el_elvia_token'] apiUrl = "https://elvia.azure-api.net/customer/metervalues/api/v1/metervalues" -pg_table = "elvia" - startTime = datetime.now(get_localzone()) - timedelta(days = 2) startTime = startTime.isoformat('T') endTime = datetime.now(get_localzone()).isoformat('T') @@ -53,4 +51,4 @@ for item in data['meteringpoints'][0]['metervalue']['timeSeries']: # Count new rows and insert -dbi("INSERT INTO " + pg_table + " VALUES(%s,%s,%s,%s,%s,%s) ON CONFLICT (startTime,endTime) DO NOTHING", values, verbose=True) +common.dbi(common.sql[common.name], values, verbose=True) -- cgit v1.2.3