Update app.py
Browse files
app.py
CHANGED
@@ -32,15 +32,10 @@ def init_db(db_name):
|
|
32 |
tA TEXT,
|
33 |
hDm TEXT,
|
34 |
sVen TEXT,
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
rPH TEXT,
|
40 |
-
rEC TEXT,
|
41 |
-
rSl TEXT,
|
42 |
-
rLe TEXT,
|
43 |
-
alW TEXT
|
44 |
)
|
45 |
''')
|
46 |
|
@@ -58,15 +53,10 @@ globs.tS = 0
|
|
58 |
globs.tA = 0
|
59 |
globs.hDm = 0
|
60 |
globs.sVen = 0
|
61 |
-
globs.
|
62 |
-
globs.
|
63 |
-
globs.
|
64 |
-
|
65 |
-
globs.rPH = 0
|
66 |
-
globs.rEC = 0
|
67 |
-
globs.rSl = 0
|
68 |
-
globs.rLe = 0
|
69 |
-
globs.alW = 0
|
70 |
|
71 |
globs.ph_eep = 0
|
72 |
globs.ph_on_eep = 0
|
@@ -96,13 +86,13 @@ def save_data_to_db(db_name, data):
|
|
96 |
# Вставляем данные в таблицу
|
97 |
cursor.execute('''
|
98 |
INSERT INTO system_data (
|
99 |
-
date_time, dey, wek, v_hid, v_min, ph, ec, tS, tA, hDm, sVen,
|
100 |
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
101 |
''', (
|
102 |
current_time, # Дата и время
|
103 |
data['dey'], data['wek'], data['v_hid'], data['v_min'], data['ph'], data['ec'],
|
104 |
-
data['tS'], data['tA'], data['hDm'], data['sVen'], data['
|
105 |
-
data['
|
106 |
))
|
107 |
|
108 |
conn.commit()
|
@@ -128,19 +118,13 @@ def sav_db_api():
|
|
128 |
'tA': request.args.get('tA'),
|
129 |
'hDm': request.args.get('hDm'),
|
130 |
'sVen': request.args.get('sVen'),
|
131 |
-
'
|
132 |
-
'
|
133 |
-
'
|
134 |
-
'rRas': request.args.get('rRas'),
|
135 |
-
'rPH': request.args.get('rPH'),
|
136 |
-
'rEC': request.args.get('rEC'),
|
137 |
-
'rSl': request.args.get('rSl'),
|
138 |
-
'rLe': request.args.get('rLe'),
|
139 |
-
'alW': request.args.get('alW')
|
140 |
}
|
141 |
|
142 |
# Проверяем, что все необходимые параметры переданы
|
143 |
-
required_params = ['dey', 'wek', 'v_hid', 'v_min', 'ph', 'ec', 'tS', 'tA', 'hDm', 'sVen', '
|
144 |
for param in required_params:
|
145 |
if data[param] is None:
|
146 |
return jsonify({'status': 'error', 'message': f'Отсутствует параметр: {param}'}), 400
|
|
|
32 |
tA TEXT,
|
33 |
hDm TEXT,
|
34 |
sVen TEXT,
|
35 |
+
onA TEXT,
|
36 |
+
onB TEXT,
|
37 |
+
onC TEXT,
|
38 |
+
|
|
|
|
|
|
|
|
|
|
|
39 |
)
|
40 |
''')
|
41 |
|
|
|
53 |
globs.tA = 0
|
54 |
globs.hDm = 0
|
55 |
globs.sVen = 0
|
56 |
+
globs.onA = 0
|
57 |
+
globs.onB = 0
|
58 |
+
globs.onC = 0
|
59 |
+
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
globs.ph_eep = 0
|
62 |
globs.ph_on_eep = 0
|
|
|
86 |
# Вставляем данные в таблицу
|
87 |
cursor.execute('''
|
88 |
INSERT INTO system_data (
|
89 |
+
date_time, dey, wek, v_hid, v_min, ph, ec, tS, tA, hDm, sVen, onA, onB, onC
|
90 |
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
91 |
''', (
|
92 |
current_time, # Дата и время
|
93 |
data['dey'], data['wek'], data['v_hid'], data['v_min'], data['ph'], data['ec'],
|
94 |
+
data['tS'], data['tA'], data['hDm'], data['sVen'], data['onA'], data['onB'],
|
95 |
+
data['onC']
|
96 |
))
|
97 |
|
98 |
conn.commit()
|
|
|
118 |
'tA': request.args.get('tA'),
|
119 |
'hDm': request.args.get('hDm'),
|
120 |
'sVen': request.args.get('sVen'),
|
121 |
+
'onA': request.args.get('onA'),
|
122 |
+
'onB': request.args.get('onB'),
|
123 |
+
'onC': request.args.get('onC')
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
}
|
125 |
|
126 |
# Проверяем, что все необходимые параметры переданы
|
127 |
+
required_params = ['dey', 'wek', 'v_hid', 'v_min', 'ph', 'ec', 'tS', 'tA', 'hDm', 'sVen', 'onA', 'onB', 'onC']
|
128 |
for param in required_params:
|
129 |
if data[param] is None:
|
130 |
return jsonify({'status': 'error', 'message': f'Отсутствует параметр: {param}'}), 400
|