Spaces:
Sleeping
Sleeping
DmitrMakeev
commited on
Commit
•
6421d95
1
Parent(s):
5584ab1
Update my_sqlite.py
Browse files- my_sqlite.py +98 -0
my_sqlite.py
CHANGED
@@ -1,5 +1,10 @@
|
|
1 |
import sqlite3
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
def create_database_and_table():
|
4 |
# Создание подключения к базе данных SQLite
|
5 |
conn = sqlite3.connect('mydatabase.db')
|
@@ -26,3 +31,96 @@ def create_database_and_table():
|
|
26 |
conn.commit()
|
27 |
cur.close()
|
28 |
conn.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import sqlite3
|
2 |
|
3 |
+
from flask import request, jsonify
|
4 |
+
import globs
|
5 |
+
import os
|
6 |
+
api_variable = os.getenv('api_key_s')
|
7 |
+
|
8 |
def create_database_and_table():
|
9 |
# Создание подключения к базе данных SQLite
|
10 |
conn = sqlite3.connect('mydatabase.db')
|
|
|
31 |
conn.commit()
|
32 |
cur.close()
|
33 |
conn.close()
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
|
44 |
+
|
45 |
+
globs.eep_set = 0
|
46 |
+
globs.ph_set = "5.55"
|
47 |
+
globs.ph_on_set = "2.5"
|
48 |
+
globs.ec_set = "1.00"
|
49 |
+
globs.ec_A_set = "2.5"
|
50 |
+
globs.ec_B_set = "2.5"
|
51 |
+
globs.ec_C_set = "2.5"
|
52 |
+
globs.l_ON_h_set = "10"
|
53 |
+
globs.l_ON_m_set = "30"
|
54 |
+
globs.l_OFF_h_set = "22"
|
55 |
+
globs.l_OFF_m_set = "30"
|
56 |
+
globs.ec_t_Voz_set = "27"
|
57 |
+
def sql_save():
|
58 |
+
err = 0
|
59 |
+
|
60 |
+
# Проверяем условие и выполняем кусок кода, если условие истинно
|
61 |
+
if api_variable == request.args.get('api'):
|
62 |
+
# Вставьте сюда ваш кусок кода, который должен выполняться, если условие истинно
|
63 |
+
# Читаем значение параметра и заносим в глобальную переменную
|
64 |
+
globs.dey = request.args.get('dey')
|
65 |
+
globs.wek = request.args.get('wek')
|
66 |
+
globs.v_hid = request.args.get('v_hid')
|
67 |
+
globs.v_min = request.args.get('v_min')
|
68 |
+
globs.ph = request.args.get('ph')
|
69 |
+
globs.ec = request.args.get('ec')
|
70 |
+
globs.tS = request.args.get('tS')
|
71 |
+
globs.tA = request.args.get('tA')
|
72 |
+
globs.hDm = request.args.get('hDm')
|
73 |
+
globs.sVen = request.args.get('sVen')
|
74 |
+
|
75 |
+
globs.rFul = request.args.get('rFul')
|
76 |
+
globs.rLi = request.args.get('rLi')
|
77 |
+
globs.rWat = request.args.get('rWat')
|
78 |
+
globs.rRas = request.args.get('rRas')
|
79 |
+
globs.rPH = request.args.get('rPH')
|
80 |
+
globs.rEC = request.args.get('rEC')
|
81 |
+
globs.rSl = request.args.get('rSl')
|
82 |
+
globs.rLe = request.args.get('rLe')
|
83 |
+
globs.alW = request.args.get('alW')
|
84 |
+
|
85 |
+
globs.ph_eep = request.args.get('ph_eep')
|
86 |
+
globs.ph_on_eep = request.args.get('ph_on_eep')
|
87 |
+
globs.ec_eep = request.args.get('ec_eep')
|
88 |
+
globs.ec_A_eep = request.args.get('ec_A_eep')
|
89 |
+
globs.ec_B_eep = request.args.get('ec_B_eep')
|
90 |
+
globs.ec_C_eep = request.args.get('ec_C_eep')
|
91 |
+
|
92 |
+
globs.l_ON_h_eep = request.args.get('l_ON_h_eep')
|
93 |
+
globs.l_ON_m_eep = request.args.get('l_ON_m_eep')
|
94 |
+
globs.l_OFF_h_eep = request.args.get('l_OFF_h_eep')
|
95 |
+
globs.l_OFF_m_eep = request.args.get('l_OFF_m_eep')
|
96 |
+
globs.t_Voz_eep = request.args.get('t_Voz_eep')
|
97 |
+
|
98 |
+
err = 1
|
99 |
+
pass
|
100 |
+
else:
|
101 |
+
# Вставьте сюда ваш кусок кода, который должен выполняться, если условие ложно
|
102 |
+
|
103 |
+
err = 0
|
104 |
+
pass
|
105 |
+
|
106 |
+
# Создаем JSON-объект
|
107 |
+
response = {
|
108 |
+
"1_ph_set": globs.ph_set,
|
109 |
+
"2_ph_on_set": globs.ph_on_set,
|
110 |
+
"3_ec_set": globs.ec_set,
|
111 |
+
"4_ec_A_set": globs.ec_A_set,
|
112 |
+
"5_ec_B_set": globs.ec_B_set,
|
113 |
+
"6_ec_C_set": globs.ec_C_set,
|
114 |
+
"7_l_ON_h_set": globs.l_ON_h_set,
|
115 |
+
"7_l_ON_m_set": globs.l_ON_m_set,
|
116 |
+
"8_l_OFF_h_set": globs.l_OFF_h_set,
|
117 |
+
"8_l_OFF_m_set": globs.l_OFF_m_set,
|
118 |
+
"9_ec_t_Voz_set": globs.ec_t_Voz_set,
|
119 |
+
"eep_set": globs.eep_set,
|
120 |
+
"err": err
|
121 |
+
}
|
122 |
+
|
123 |
+
# Возвращаем JSON-объект
|
124 |
+
return jsonify(response)
|
125 |
+
|
126 |
+
|