DmitrMakeev
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1228,19 +1228,16 @@ def insert_data(data):
|
|
1228 |
n_con = row.get('n_con', '')
|
1229 |
canal = row.get('canal', '')
|
1230 |
|
1231 |
-
# Создание динамического SQL-запроса с использованием INSERT
|
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 |
|
1235 |
placeholders = ', '.join(['?' for _ in columns])
|
1236 |
columns_str = ', '.join(columns)
|
1237 |
-
update_str = ', '.join([f'{col} = excluded.{col}' for col in columns])
|
1238 |
|
1239 |
query = f'''
|
1240 |
-
INSERT INTO contacts ({columns_str})
|
1241 |
VALUES ({placeholders})
|
1242 |
-
ON CONFLICT(email) DO UPDATE SET
|
1243 |
-
{update_str}
|
1244 |
'''
|
1245 |
|
1246 |
try:
|
|
|
1228 |
n_con = row.get('n_con', '')
|
1229 |
canal = row.get('canal', '')
|
1230 |
|
1231 |
+
# Создание динамического SQL-запроса с использованием INSERT OR REPLACE
|
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 |
|
1235 |
placeholders = ', '.join(['?' for _ in columns])
|
1236 |
columns_str = ', '.join(columns)
|
|
|
1237 |
|
1238 |
query = f'''
|
1239 |
+
INSERT OR REPLACE INTO contacts ({columns_str})
|
1240 |
VALUES ({placeholders})
|
|
|
|
|
1241 |
'''
|
1242 |
|
1243 |
try:
|