aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/elvia.py
diff options
context:
space:
mode:
authorDennis Eriksen <d@ennis.no>2023-02-04 20:23:14 +0100
committerDennis Eriksen <d@ennis.no>2023-02-04 20:23:21 +0100
commit3c9a54e0958e7c0341e470f508e5fbc6db920388 (patch)
tree3d9cb86bcb6454f6f615c5dc71388ac12c75c434 /scripts/elvia.py
parentadding variable to env.sample (diff)
downloadenergyscripts-3c9a54e0958e7c0341e470f508e5fbc6db920388.tar.gz
sql-variables in common was stupid. put them where they are used
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)