Answer the question
In order to leave comments, you need to log in
Error in sqlite3, help?
Greetings. I ran into a problem, writes that sqlite.cursor does not support the "<" sign, or I did something wrong.
TypeError: '<' not supported between instances of 'sqlite3.Cursor' and 'int'
@client.command(aliases = ['казино','casino'])
async def casino(ctx, arg:int=None):
winandlosing = ['Выиграли', 'Проиграли']
if arg is None:
await ctx.send(f'{ctx.author.mention}, укажите количество на которое хотите сыграть')
else:
cash = cursor.execute(f"SELECT cash FROM users WHERE id = {ctx.author.id}")
if cash < arg:
await ctx.send(f'{ctx.author.mention}, у вас недостаточно денег.')
else:
da = await ctx.send(f'{ctx.author.mention}, вы {random.choice(winandlosing)}')
if da == 'Выиграли':
win = arg*2
cursor.execute(f'UPDATE users SET cash = {win} WHERE id = {ctx.author.id} ')
await ctx.send(f'{ctx.author.mention}, вы выиграли, поздравляю, ваш выигрыш удвоен.')
if da == 'Проиграли':
cursor.execute(F"UPDATE users SET cash = {arg} WHERE id = {ctx.author.id}")
await ctx.send(f'{ctx.author.mention}, вы проиграли, в следующий раз повезёт.')
Answer the question
In order to leave comments, you need to log in
cursor.execute returns an iterable result generator. You can either run through it:
for row in cursor.execute(...):
cash, = row
# или
cash = row[0]
res = cursor.execute(...)
res_list = res.fetchall()
cash = res_list[0][0]
Convert types.
You have a mistake here:
if cash < arg:
You are comparing them as numbers, but, apparently, cash is not a number. Do:
(int)cash
Should help.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question