|
@@ -12,6 +12,22 @@ class VariableValue(RowClass):
|
12
|
12
|
def __init__(self, **kwargs):
|
13
|
13
|
super().__init__(**kwargs)
|
14
|
14
|
|
|
15
|
+ def insert(self):
|
|
16
|
+ try:
|
|
17
|
+ sql(
|
|
18
|
+ """
|
|
19
|
+ INSERT INTO var_value
|
|
20
|
+ (type, address, value)
|
|
21
|
+ VALUES
|
|
22
|
+ ('{}', {}, {})
|
|
23
|
+ """.format(
|
|
24
|
+ self.type, self.address, self.vaule
|
|
25
|
+ ))
|
|
26
|
+ return True
|
|
27
|
+ except Exception as e:
|
|
28
|
+ print(e)
|
|
29
|
+ return False
|
|
30
|
+
|
15
|
31
|
@staticmethod
|
16
|
32
|
def get(type, address, time=datetime.now()):
|
17
|
33
|
try:
|
|
@@ -25,8 +41,8 @@ class VariableValue(RowClass):
|
25
|
41
|
ORDER BY time DESC
|
26
|
42
|
LIMIT 1
|
27
|
43
|
""".format(
|
28
|
|
- type, address, int(time.strftime('%s'))+1)
|
29
|
|
- ))
|
|
44
|
+ type, address, int(time.strftime('%s'))+1
|
|
45
|
+ )))
|
30
|
46
|
return VariableValue(**dict(row))
|
31
|
47
|
except StopIteration as e:
|
32
|
48
|
raise e
|