def mysql_update_discord_rank_data(author, rank_data):
mydb, mycursor = connect_to_mysql()
print(rank_data)
mycursor.execute(f'UPDATE discord_levels SET `xp`={rank_data["xp"]}
, `level`={rank_data["level"]}, `message_count`={rank_data["message_count"]}
WHERE `discord_id`="{author.id}";')
mydb.commit()
mycursor.close()
mydb.close()
This is the code that is giving me issues.
I am attempting to modify xp
, level
, and message_count
in the database table discord_levels
.
The MySQL connection is good, I am running other queries just fine, it's just this one giving me issues.
The MySQL query is also good, I have tried it in the MySQL console hoping that was the reason, unfortunately it wasn't.
The thing is, the xp
and level
columns are being updated accordingly, although the message_count
column does not want to update at all. I have tried running the following MySQL query alone as well, to no avail (with a database commit afterwards).
mycursor.execute(f'UPDATE discord_levels SET `message_count`={int(rank_data["message_count"])} WHERE `discord_id`="{author.id}";')
I have checked if the value is actually being updated before the query is run, so I know that is also not the issue.
Does anyone have any idea on a fix for this or any idea as to what I am doing wrong?
question from:
https://stackoverflow.com/questions/65852377/python-mysql-connector-update-statement-not-updating-all-values 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…