DmitrMakeev
commited on
Commit
•
e638fd6
1
Parent(s):
e04a349
Update app.py
Browse files
app.py
CHANGED
@@ -1187,7 +1187,6 @@ def parse_csv_data(data):
|
|
1187 |
parsed_data.append(dict(zip(headers, row)))
|
1188 |
return parsed_data
|
1189 |
|
1190 |
-
|
1191 |
def insert_data(data):
|
1192 |
conn = sqlite3.connect(DATABASE2)
|
1193 |
cursor = conn.cursor()
|
@@ -1229,7 +1228,7 @@ def insert_data(data):
|
|
1229 |
n_con = row.get('n_con', '')
|
1230 |
canal = row.get('canal', '')
|
1231 |
|
1232 |
-
# Создание динамического SQL-запроса с использованием INSERT
|
1233 |
columns = ['name', 'phone', 'email', 'vk_id', 'chat_id', 'ws_st', 'ws_stop', 'web_st', 'fin_prog', 'b_city', 'b_fin', 'b_ban', 'b_ign', 'b_baners', 'b_butt', 'b_mess', 'shop_st', 'curator', 'pr1', 'pr2', 'pr3', 'pr4', 'pr5', 'ad_url', 'key_pr', 'n_con', 'canal', 'data_t']
|
1234 |
values = [name, phone, email, vk_id, chat_id, ws_st, ws_stop, web_st, fin_prog, b_city, b_fin, b_ban, b_ign, b_baners, b_butt, b_mess, shop_st, curator, pr1, pr2, pr3, pr4, pr5, ad_url, key_pr, n_con, canal, data_t]
|
1235 |
|
@@ -1237,8 +1236,9 @@ def insert_data(data):
|
|
1237 |
columns_str = ', '.join(columns)
|
1238 |
|
1239 |
query = f'''
|
1240 |
-
INSERT
|
1241 |
VALUES ({placeholders})
|
|
|
1242 |
'''
|
1243 |
|
1244 |
try:
|
@@ -1252,6 +1252,7 @@ def insert_data(data):
|
|
1252 |
conn.commit()
|
1253 |
conn.close()
|
1254 |
|
|
|
1255 |
@app.route('/upload_csv', methods=['POST'])
|
1256 |
def upload_csv():
|
1257 |
if 'file' not in request.files:
|
|
|
1187 |
parsed_data.append(dict(zip(headers, row)))
|
1188 |
return parsed_data
|
1189 |
|
|
|
1190 |
def insert_data(data):
|
1191 |
conn = sqlite3.connect(DATABASE2)
|
1192 |
cursor = conn.cursor()
|
|
|
1228 |
n_con = row.get('n_con', '')
|
1229 |
canal = row.get('canal', '')
|
1230 |
|
1231 |
+
# Создание динамического SQL-запроса с использованием INSERT ... ON CONFLICT DO NOTHING
|
1232 |
columns = ['name', 'phone', 'email', 'vk_id', 'chat_id', 'ws_st', 'ws_stop', 'web_st', 'fin_prog', 'b_city', 'b_fin', 'b_ban', 'b_ign', 'b_baners', 'b_butt', 'b_mess', 'shop_st', 'curator', 'pr1', 'pr2', 'pr3', 'pr4', 'pr5', 'ad_url', 'key_pr', 'n_con', 'canal', 'data_t']
|
1233 |
values = [name, phone, email, vk_id, chat_id, ws_st, ws_stop, web_st, fin_prog, b_city, b_fin, b_ban, b_ign, b_baners, b_butt, b_mess, shop_st, curator, pr1, pr2, pr3, pr4, pr5, ad_url, key_pr, n_con, canal, data_t]
|
1234 |
|
|
|
1236 |
columns_str = ', '.join(columns)
|
1237 |
|
1238 |
query = f'''
|
1239 |
+
INSERT INTO contacts ({columns_str})
|
1240 |
VALUES ({placeholders})
|
1241 |
+
ON CONFLICT(email) DO NOTHING
|
1242 |
'''
|
1243 |
|
1244 |
try:
|
|
|
1252 |
conn.commit()
|
1253 |
conn.close()
|
1254 |
|
1255 |
+
|
1256 |
@app.route('/upload_csv', methods=['POST'])
|
1257 |
def upload_csv():
|
1258 |
if 'file' not in request.files:
|