V
V
Vladislav2021-12-24 19:18:29
Python
Vladislav, 2021-12-24 19:18:29

How to fix "'tuple' object has no attribute 'chat'"?

def incodetype1(message):
    code = message.text
    conn = sqlite3.connect("users.db", check_same_thread=False)
    cursor = conn.cursor()
    cursor.execute('SELECT message FROM bdmes WHERE keyaccess = ?', [code])
    for message in cursor.fetchall():
     bot.send_message(message.chat.id, 'Сообщение: ' + str(message))

Mistake:

bot.send_message(message.chat.id, 'Сообщение: ' + str(message))
AttributeError: 'tuple' object has no attribute 'chat'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-12-24
Likov @Laziff

Do not overlap the function argument with the loop variable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question