I wrote a bot on aiogram, but it doesn't work the way I need it to. It does not save data to the database from time to time. Checked by the sqlite studio utility. after I wrote the algorithm I confirm it db.commit(), but the data is somehow not saved to the database how to fix it?
def fight(user_id:int):
for mob_id,hp_mob,damage_mob,power_mob,armor_mob in sql.execute(f"SELECT mob_id,hp_mob,damage_mob,power_mob, armor_mob FROM mob WHERE user_id = '{user_id }'").fetchall():
for hp,damage,power,armor, in sql.execute(f"SELECT hp, damage, power, armor FROM profile WHERE user_id = '{user_id }'"). fetchall():
damage = (power_mob - armor)
damage_mob = (power - armor_mob)
hp -= damage_mob
hp_mob -= damage
sql.execute(f"UPDATE profile SET hp == '{hp}', damage == '{damage}' WHERE user_id = 'user_id '")
db.commit()
sql.execute(f"UPDATE mob SET hp_mob == '{hp_mob}', damage_mob == '{damage_mob}' WHERE user_id = 'user_id '")
db.commit()
print(damage)
print(damage_mob)