diff options
Diffstat (limited to 'scripts/elvia.py')
-rw-r--r-- | scripts/elvia.py | 6 |
1 files changed, 2 insertions, 4 deletions
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) |