DmitrMakeev
commited on
Commit
•
21643d8
1
Parent(s):
a78c733
Update app.py
Browse files
app.py
CHANGED
@@ -1157,10 +1157,11 @@ def se_upl_csv():
|
|
1157 |
return "EUR 22", 200
|
1158 |
return render_template('upl_csv.html')
|
1159 |
|
1160 |
-
|
1161 |
|
1162 |
def insert_data(data):
|
1163 |
-
|
|
|
1164 |
cursor = conn.cursor()
|
1165 |
for row in data:
|
1166 |
# Получение текущего времени в московском часовом поясе
|
@@ -1174,10 +1175,17 @@ def insert_data(data):
|
|
1174 |
phone = row.get('phone', '')
|
1175 |
email = row.get('email', '')
|
1176 |
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1181 |
conn.commit()
|
1182 |
conn.close()
|
1183 |
|
|
|
1157 |
return "EUR 22", 200
|
1158 |
return render_template('upl_csv.html')
|
1159 |
|
1160 |
+
|
1161 |
|
1162 |
def insert_data(data):
|
1163 |
+
DATABASE = 'data_gc.db'
|
1164 |
+
conn = sqlite3.connect(DATABASE)
|
1165 |
cursor = conn.cursor()
|
1166 |
for row in data:
|
1167 |
# Получение текущего времени в московском часовом поясе
|
|
|
1175 |
phone = row.get('phone', '')
|
1176 |
email = row.get('email', '')
|
1177 |
|
1178 |
+
try:
|
1179 |
+
cursor.execute('''
|
1180 |
+
INSERT INTO contacts (name, phone, email, data_t)
|
1181 |
+
VALUES (?, ?, ?, ?)
|
1182 |
+
''', (name, phone, email, data_t))
|
1183 |
+
except Exception as e:
|
1184 |
+
print(f"Error inserting row: {row}")
|
1185 |
+
print(f"Error message: {str(e)}")
|
1186 |
+
conn.rollback()
|
1187 |
+
raise
|
1188 |
+
|
1189 |
conn.commit()
|
1190 |
conn.close()
|
1191 |
|