Answer the question
In order to leave comments, you need to log in
How to fix can "only concatenate tuple (not "str") to tuple" error?
Good evening. I am writing a bot. The essence is simple, the user clicks on the desired button, and then the bot edits the message to the text that the code forms by pulling the text from several SQLite database cells. I am using the PyTelegramBotApi library. What caused the error and how to avoid it? Thanks in advance to everyone for your help.
Mistake:
File "bot.py", line 244, in callback_inline
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text=product_name('bud1') + "\n" + "-----------------\n" + product_about('bud1') + "\n" + "\n"+"Цена: "+product_price('bud1'), parse_mode='html', reply_markup=markup)
TypeError: can only concatenate tuple (not "str") to tuple
def product_name(id ):
with sqlite3.connect('database.db') as connection:
cursor = connection.cursor()
cursor.execute("SELECT `name` FROM `catalog` WHERE `id` = ? ", (id,))
result = cursor.fetchone()
return result
def product_about(id ):
with sqlite3.connect('database.db') as connection:
cursor = connection.cursor()
cursor.execute("SELECT `about` FROM `catalog` WHERE `id` = ? ", (id,))
result = cursor.fetchone()
return result
def product_price(id ):
with sqlite3.connect('database.db') as connection:
cursor = connection.cursor()
cursor.execute("SELECT `price` FROM `catalog` WHERE `id` = ? ", (id,))
result = cursor.fetchone()
return result
if call.data == 'bud-1':
markup = types.InlineKeyboardMarkup(row_width=1)
item1 = types.InlineKeyboardButton("Назад", callback_data='bud')
markup.add(item1)
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text=product_name('bud1') + "\n" + "-----------------\n" + product_about('bud1') + "\n" + "\n"+"Цена: "+product_price('bud1'), parse_mode='html', reply_markup=markup)
Answer the question
In order to leave comments, you need to log in
TypeError: can only concatenate tuple (not "str") to tuple
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question