aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/elvia.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/elvia.py')
-rw-r--r--scripts/elvia.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/scripts/elvia.py b/scripts/elvia.py
index 2248238..61bc692 100644
--- a/scripts/elvia.py
+++ b/scripts/elvia.py
@@ -47,8 +47,18 @@ values = []
for item in data['meteringpoints'][0]['metervalue']['timeSeries']:
# Only deal with verified items.
if item['verified']:
- values.append((data['meteringpoints'][0]['meteringPointId'], item['startTime'], item['endTime'], item['value'], item['uom'], item['production']))
+ values.append((
+ data['meteringpoints'][0]['meteringPointId'],
+ item['startTime'],
+ item['endTime'],
+ item['value'],
+ item['uom'],
+ item['production']))
-# Count new rows and insert
-common.dbi(common.sql[common.name], values, verbose=True)
+# SQL
+sql = """ INSERT INTO elvia
+ VALUES(%s, %s, %s, %s, %s, %s)
+ ON CONFLICT (startTime,endTime) DO NOTHING;"""
+
+common.dbi(sql, values, verbose=True)