Answer the question
In order to leave comments, you need to log in
How to compare data from a table with null?
Tell me how you can compare the data from the table with zero
. There is such a code:
@bot.command(aliases = ['warn'])
async def __warn(ctx, member: discord.Member = None, arg: int = None):
print('1')
if member is None:
await ctx.send('Пользователь')
print('2')
elif arg is None:
await ctx.send('Причина')
print('3')
else:
for i in cursor.execute("SELECT Wreason FROM users WHERE id = {}".format(member.id)).fetchone():
if i == 0:
print('4')
cursor.execute("UPDATE users SET warns = warns + {1} WHERE id = {}".format(member.id))
cursor.execute("UPDATE users SET Wreason = Wreason + {} WHERE id = {}".format(arg, member.id))
Answer the question
In order to leave comments, you need to log in
Instead of
for i in cursor.execute("SELECT Wreason FROM users WHERE id = {}".format(member.id)).fetchone():
if i == 0:
print('4')
cursor.execute("UPDATE users SET warns = warns + {1} WHERE id = {}".format(member.id))
cursor.execute("UPDATE users SET Wreason = Wreason + {} WHERE id = {}".format(arg, member.id))
cursor.execute("UPDATE users SET warns = warns + 1, Wreason = {} WHERE id = {} AND Wreason = 0".format(arg, member.id))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question