Update app.py
Browse files
app.py
CHANGED
@@ -89,7 +89,25 @@ globs.t_Voz_eep = 0
|
|
89 |
app = flask.Flask(__name__, template_folder="./")
|
90 |
app.config['DEBUG'] = True
|
91 |
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
def save_data_to_db(db_name, data):
|
94 |
try:
|
95 |
conn = sqlite3.connect(db_name)
|
|
|
89 |
app = flask.Flask(__name__, template_folder="./")
|
90 |
app.config['DEBUG'] = True
|
91 |
|
92 |
+
|
93 |
+
# Функция сохранения в базу пользователей TG
|
94 |
+
def save_user(chat_id, db_name="your_database.db"):
|
95 |
+
conn = sqlite3.connect(db_name)
|
96 |
+
cursor = conn.cursor()
|
97 |
+
|
98 |
+
created_at = datetime.now().isoformat() # Форматируем дату
|
99 |
+
|
100 |
+
try:
|
101 |
+
cursor.execute("INSERT INTO bot_users (chat_id, created_at) VALUES (?, ?)", (chat_id, created_at))
|
102 |
+
conn.commit()
|
103 |
+
except sqlite3.IntegrityError:
|
104 |
+
print(f"Пользователь {chat_id} уже есть в базе.")
|
105 |
+
|
106 |
+
conn.close()
|
107 |
+
|
108 |
+
|
109 |
+
|
110 |
+
# Функция сохранения в базу данных системы автоматизации гидропоники
|
111 |
def save_data_to_db(db_name, data):
|
112 |
try:
|
113 |
conn = sqlite3.connect(db_name)
|