cursor.execute(f"SELECT user_id, Class, Health, Mana, Defense, Maxmana, Maxhealth, Attack, Critical FROM savefile WHERE user_id = '{message.author.id}'") result1 = cursor.fetchone() classs = int(result1[1]); health = int(result1[2]); mana = int(result1[3]); defense = int(result1[4]); attack = int(result1[7]); critical = int(result1[8]) sql = "UPDATE savefile SET Class = ? AND SET Health = ? AND SET Mana = ? AND SET Defense = ? AND SET Maxmana = ? AND SET Maxhealth = ? AND SET Attack = ? AND SET Critical = ? WHERE user_id = ?" val = (classs + classplus, str(message.author.id), health + healthplus, str(message.author.id), mana + manaplus, str(message.author.id), defense + defenseplus, str(message.author.id), attack + attackplus, str(message.author.id), critical + criticalplus, str(message.author.id)) cursor.execute(sql, val) db.commit()
This is a chunk of the code I am using. I am currently making a discord bot, and have several other commands that add to a column. However, on the “classs = …” line, the third line in my code shown above, (extra S is on purpose) I get this error:
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
I am relatively new to using sqlite in general, and do not understand why this is happening. I have code similar to this in my other bot commands, and do not understand why this specifically does not work. Thank you for any help in advance!
Advertisement
Answer
One of these results (result1[i]) most likely is of NoneType, meaning there is no data retrieved from the database:
classs = int(result1[1]); health = int(result1[2]); mana = int(result1[3]); defense = int(result1[4]); attack = int(result1[7]); critical = int(result1[8])