A
A
Alexey Mikhalev2020-07-19 19:00:39
Python
Alexey Mikhalev, 2020-07-19 19:00:39

What caused the error when getting data from a SQLite database?

I am writing a bot. I wrote a code that retrieves data from the database and the bot displays them in the cart. But it all ends with the fact that when I click on the button in the bot, which should display the information from the database, a spam of an incomprehensible error appears in the console. What causes it and how to avoid it?

2020-07-19 18:31:36,338 (__init__.py:455 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 414 Request-URI Too Large. Response body:
[b'<html>\r\n<head><title>414 Request-URI Too Large</title></head>\r\n<body>\r\n<center><h1>414 Request-URI Too Large</h1></center>\r\n<hr><center>nginx/1.16.1</center>\r\n</body>\r\n</html>\r\n']"

UPD:
I use the pytelegrambotapi library. I am attaching code snippets below.
Access to the database:
def product(name ):
    with sqlite3.connect('database.db') as connection:
        cursor = connection.cursor()
        cursor.execute("SELECT * FROM catalog WHERE name = ? ", (name,))
        result = cursor.fetchone()
        return result

Data output to the bot:
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('bud1'), parse_mode='html', reply_markup=markup)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Emir2010, 2021-04-03
@Emir2010

Most likely the problem is related to the fact that the length of the message you are sending exceeds the allowed value (if I'm not mistaken, it is 4096 characters).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question