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/elvia_gridtariff.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/elvia_gridtariff.py')
-rw-r--r-- | scripts/elvia_gridtariff.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/scripts/elvia_gridtariff.py b/scripts/elvia_gridtariff.py index 60692b4..2e398b3 100644 --- a/scripts/elvia_gridtariff.py +++ b/scripts/elvia_gridtariff.py @@ -59,6 +59,18 @@ print("Got "+ str(len(data['gridTariffCollections'][0]['gridTariff']['tariffPric values = [] for item in data['gridTariffCollections'][0]['gridTariff']['tariffPrice']['hours']: - values.append((meteringPointId, item['startTime'], item['expiredAt'], item['shortName'], item['isPublicHoliday'], item['energyPrice']['total'], item['energyPrice']['totalExVat'])) - -common.dbi(common.sql[common.name], values, verbose=True) + values.append(( + meteringPointId, + item['startTime'], + item['expiredAt'], + item['shortName'], + item['isPublicHoliday'], + item['energyPrice']['total'], + item['energyPrice']['totalExVat'])) + +# SQL +sql = """ INSERT INTO elvia_gridtariff + VALUES(%s, %s, %s, %s, %s, %s, %s) + ON CONFLICT (meteringPointId,startTime,endTime) DO NOTHING""" + +common.dbi(sql, values, verbose=True) |