1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#!/usr/bin/env python3
''' common functions and stuff '''
import os
import sys
QUEUE = bool(os.environ.get('el_QUEUE', False))
name = os.path.splitext(os.path.split(sys.argv[0])[-1])[0]
sql = {
'elvia': """
INSERT INTO
elvia
VALUES(%s, %s, %s, %s, %s, %s)
ON CONFLICT (startTime,endTime) DO NOTHING""",
'elvia_gridtariff': """
INSERT INTO
elvia_gridtariff
VALUES(%s, %s, %s, %s, %s, %s, %s)
ON CONFLICT (meteringPointId,startTime,endTime) DO NOTHING""",
'entsoe': """
INSERT INTO
entsoe
VALUES(%s, %s, %s)
ON CONFLICT (starttime, zone) DO NOTHING""",
'nb': """
INSERT INTO
nbex
VALUES(%s, %s, %s, %s)
ON CONFLICT (startdate,base_cur,quote_cur) DO NOTHING""",
'neohub': """
INSERT INTO
neohub
(timestamp,
time,
device_id,
away,
heat_mode,
heat_on,
current_floor_temperature,
target_temperature,
temperature)
VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s)""",
'tibber_consumption': """
INSERT INTO
tibber_consumption
VALUES(%s, %s, %s, %s, %s, %s, %s)
ON CONFLICT (startTime,endTime) DO NOTHING""",
'tibber_prices': """
INSERT INTO
tibber_prices
VALUES(%s, %s, %s, %s, %s)
ON CONFLICT (startsat) DO NOTHING""",
'yr': """
INSERT INTO
yr
VALUES(%s, %s, %s, %s, %s, %s, %s)
ON CONFLICT (time) DO UPDATE SET
air_temperature=EXCLUDED.air_temperature,
air_pressure_at_sea_level=EXCLUDED.air_pressure_at_sea_level,
cloud_area_fraction=EXCLUDED.cloud_area_fraction,
relative_humidity=EXCLUDED.relative_humidity,
wind_from_direction=EXCLUDED.wind_from_direction,
wind_speed=EXCLUDED.wind_speed,
updated=now()""",
}
# Initialize queue
if QUEUE is True:
from .queue import dbi
else:
from .postgres import dbi
|