Сбор и сохранение рецептом и ссылок в json
This commit is contained in:
@@ -7,10 +7,16 @@ def connect_to_mongo():
|
||||
return db["Test"]
|
||||
|
||||
|
||||
def import_json_in_mongo(data):
|
||||
def import_json_in_mongo(recipe_data):
|
||||
collection = connect_to_mongo()
|
||||
collection.insert_one(data)
|
||||
|
||||
|
||||
print(recipe_data)
|
||||
|
||||
try:
|
||||
collection.replace_one({"_id": recipe_data["_id"]}, recipe_data, upsert=True)
|
||||
print(f"Рецепт '{recipe_data.get('recipe_name', recipe_data['_id'])}' успешно сохранён.")
|
||||
except Exception as e:
|
||||
print(f"Ошибка при сохранении рецепта {recipe_data.get('_id')}: {e}")
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user