DmitrMakeev
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1788,6 +1788,16 @@ def add_user_bot(db_name, user_data, mapping_template3):
|
|
1788 |
# Преобразование данных пользователя на основе шаблона сопоставления
|
1789 |
transformed_data = {db_column: user_data.get(json_key, "") for json_key, db_column in mapping_template3.items()}
|
1790 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1791 |
columns = ', '.join(transformed_data.keys())
|
1792 |
placeholders = ', '.join('?' for _ in transformed_data)
|
1793 |
insert_query = f"INSERT INTO contacts ({columns}) VALUES ({placeholders})"
|
|
|
1788 |
# Преобразование данных пользователя на основе шаблона сопоставления
|
1789 |
transformed_data = {db_column: user_data.get(json_key, "") for json_key, db_column in mapping_template3.items()}
|
1790 |
|
1791 |
+
# Добавление недостающих полей с пустыми строками
|
1792 |
+
required_fields = [
|
1793 |
+
"ad_url", "b_ban", "b_baners", "b_butt", "b_city", "b_fin", "b_ign", "b_mess",
|
1794 |
+
"canal", "chat_id", "curator", "data_t", "fin_prog", "key_pr", "n_con",
|
1795 |
+
"pr1", "pr2", "pr3", "pr4", "pr5", "shop_st", "vk_id", "web_st", "ws_st", "ws_stop"
|
1796 |
+
]
|
1797 |
+
for field in required_fields:
|
1798 |
+
if field not in transformed_data:
|
1799 |
+
transformed_data[field] = ""
|
1800 |
+
|
1801 |
columns = ', '.join(transformed_data.keys())
|
1802 |
placeholders = ', '.join('?' for _ in transformed_data)
|
1803 |
insert_query = f"INSERT INTO contacts ({columns}) VALUES ({placeholders})"
|