aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/elvia_gridtariff.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/elvia_gridtariff.py')
-rw-r--r--scripts/elvia_gridtariff.py18
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)