Через телеграмм бот обращаюсь на БД с товарами. Но в ответ пользователь получает поочередно список товаров. Хотелось одним сообщение отправить весь список.
Отрывок из кода:
bot.register_next_step_handler(c, show_category)
def show_category (message):
chat_id = message.chat.id
user_data=message.text
cursor.execute(f'''
select product_id, title, price from products
join categories using(category_id) where category_name=%s
''', (user_data,))
category_products=cursor.fetchall()
for products in category_products:
product_id=products[0]
title=products[1]
price=products[2]
message_to_user = f'''{title}\nЦена: {price}\nПодробнее: /product_{product_id}'''
bot.send_message(chat_id, message_to_user)