F
F
Fedor2020-10-25 18:31:15
Python
Fedor, 2020-10-25 18:31:15

Why the error?

Hello
Here is the error itself:
File "C:\Users\fyodrro\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\util.py", line 60, in run
task(*args, * *kwargs)
File "bot.py", line 31, in start
user.set_balance(balance=balance)
File "D:\projects\TestInline\db_classes\user.py", line 54, in set_balance
cursor.executemany(request, balance)
TypeError: 'int' object is not iterable

Code(file with functions)

def set_balance(self,balance):
        # """Изменяет баланс"""        
        cursor = self.connect.cursor()
        request = f"UPDATE users SET balance=? WHERE id=?"
        cursor.executemany(request,balance)
        self.connect.commit()

Main file:
balance = 0
    user.set_balance(balance=balance)

How to decide?
Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2020-10-25
@srgvac

The second parameter to executemany must be an iterable sequence. The number 0 is not.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question