sql="INSERT INTO daily (compte, points, date) VALUES (%s, %s, current_date())"
val=(compte,points)
mycursor.execute(sql,val)
mydb.commit()
printf(mycursor.rowcount,"record created.")
defupdate_row(compte,points,mycursor,mydb):
sql=f"UPDATE daily SET points = {points} WHERE compte = '{compte}' AND date = current_date() ;"
mycursor.execute(sql)
mydb.commit()
printf(mycursor.rowcount,"record(s) updated")
defupdate_last(compte,points,mycursor,mydb):
sql=f"UPDATE comptes SET last_pts = {points} WHERE compte = '{compte}';"
mycursor.execute(sql)
mydb.commit()
printf(mycursor.rowcount,"record(s) updated")
defget_row(compte,points,mycursor,same_points=True):#return if there is a line with the same ammount of point or with the same name as well as the same day
ifsame_points:
mycursor.execute(f"SELECT * FROM daily WHERE points = {points} AND compte = '{compte}' AND date = current_date() ;")
else:
mycursor.execute(f"SELECT * FROM daily WHERE compte = '{compte}' AND date = current_date() ;")