DmitrMakeev
commited on
Commit
•
c469556
1
Parent(s):
21643d8
Update app.py
Browse files
app.py
CHANGED
@@ -1159,9 +1159,29 @@ def se_upl_csv():
|
|
1159 |
|
1160 |
|
1161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1162 |
def insert_data(data):
|
1163 |
-
|
1164 |
-
conn = sqlite3.connect(DATABASE)
|
1165 |
cursor = conn.cursor()
|
1166 |
for row in data:
|
1167 |
# Получение текущего времени в московском часовом поясе
|
@@ -1175,11 +1195,20 @@ def insert_data(data):
|
|
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)}")
|
@@ -1207,6 +1236,23 @@ def upload_csv():
|
|
1207 |
|
1208 |
|
1209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1210 |
|
1211 |
|
1212 |
|
|
|
1159 |
|
1160 |
|
1161 |
|
1162 |
+
|
1163 |
+
|
1164 |
+
|
1165 |
+
|
1166 |
+
|
1167 |
+
|
1168 |
+
|
1169 |
+
|
1170 |
+
|
1171 |
+
|
1172 |
+
|
1173 |
+
|
1174 |
+
|
1175 |
+
|
1176 |
+
|
1177 |
+
|
1178 |
+
|
1179 |
+
DATABASE2 = 'data_gc.db'
|
1180 |
+
|
1181 |
+
|
1182 |
+
|
1183 |
def insert_data(data):
|
1184 |
+
conn = sqlite3.connect(DATABASE2)
|
|
|
1185 |
cursor = conn.cursor()
|
1186 |
for row in data:
|
1187 |
# Получение текущего времени в московском часовом поясе
|
|
|
1195 |
phone = row.get('phone', '')
|
1196 |
email = row.get('email', '')
|
1197 |
|
1198 |
+
# Создание динамического SQL-запроса
|
1199 |
+
columns = ['name', 'phone', 'email', 'data_t']
|
1200 |
+
values = [name, phone, email, data_t]
|
1201 |
+
|
1202 |
+
placeholders = ', '.join(['?' for _ in columns])
|
1203 |
+
columns_str = ', '.join(columns)
|
1204 |
+
|
1205 |
+
query = f'''
|
1206 |
+
INSERT INTO contacts ({columns_str})
|
1207 |
+
VALUES ({placeholders})
|
1208 |
+
'''
|
1209 |
+
|
1210 |
try:
|
1211 |
+
cursor.execute(query, values)
|
|
|
|
|
|
|
1212 |
except Exception as e:
|
1213 |
print(f"Error inserting row: {row}")
|
1214 |
print(f"Error message: {str(e)}")
|
|
|
1236 |
|
1237 |
|
1238 |
|
1239 |
+
|
1240 |
+
|
1241 |
+
|
1242 |
+
|
1243 |
+
|
1244 |
+
|
1245 |
+
|
1246 |
+
|
1247 |
+
|
1248 |
+
|
1249 |
+
|
1250 |
+
|
1251 |
+
|
1252 |
+
|
1253 |
+
|
1254 |
+
|
1255 |
+
|
1256 |
|
1257 |
|
1258 |
|