DmitrMakeev
commited on
Commit
•
86e6073
1
Parent(s):
172efa1
Update app.py
Browse files
app.py
CHANGED
@@ -1693,16 +1693,14 @@ def add_or_update_contact(contact_data):
|
|
1693 |
"b_ign", "b_baners", "b_butt", "b_mess", "shop_st", "curator", "pr1", "pr2", "pr3", "pr4",
|
1694 |
"pr5", "ad_url", "key_pr", "n_con", "canal", "data_t"]
|
1695 |
|
1696 |
-
|
1697 |
-
fields_to_update = [field for field in fields if contact_data.get(field, '') != '']
|
1698 |
-
placeholders = ", ".join([f"{field} = ?" for field in fields_to_update])
|
1699 |
|
1700 |
if contact:
|
1701 |
update_query = f"UPDATE contacts SET {placeholders} WHERE id = ?"
|
1702 |
-
cursor.execute(update_query, (*[contact_data
|
1703 |
else:
|
1704 |
-
insert_query = f"INSERT INTO contacts ({', '.join(
|
1705 |
-
cursor.execute(insert_query, tuple(contact_data
|
1706 |
|
1707 |
conn.commit()
|
1708 |
conn.close()
|
@@ -1766,7 +1764,6 @@ def add_data_ver():
|
|
1766 |
|
1767 |
|
1768 |
|
1769 |
-
|
1770 |
initialize_requests()
|
1771 |
|
1772 |
|
|
|
1693 |
"b_ign", "b_baners", "b_butt", "b_mess", "shop_st", "curator", "pr1", "pr2", "pr3", "pr4",
|
1694 |
"pr5", "ad_url", "key_pr", "n_con", "canal", "data_t"]
|
1695 |
|
1696 |
+
placeholders = ", ".join([f"{field} = ?" for field in fields])
|
|
|
|
|
1697 |
|
1698 |
if contact:
|
1699 |
update_query = f"UPDATE contacts SET {placeholders} WHERE id = ?"
|
1700 |
+
cursor.execute(update_query, (*[contact_data.get(field, '') for field in fields], contact[0]))
|
1701 |
else:
|
1702 |
+
insert_query = f"INSERT INTO contacts ({', '.join(fields)}) VALUES ({', '.join(['?' for _ in fields])})"
|
1703 |
+
cursor.execute(insert_query, tuple(contact_data.get(field, '') for field in fields))
|
1704 |
|
1705 |
conn.commit()
|
1706 |
conn.close()
|
|
|
1764 |
|
1765 |
|
1766 |
|
|
|
1767 |
initialize_requests()
|
1768 |
|
1769 |
|