From 4f29e876b198778ea74a31c8cd00444a54c7da33 Mon Sep 17 00:00:00 2001 From: piair Date: Thu, 9 Jun 2022 16:23:13 +0200 Subject: [PATCH] update point --- V4.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/V4.py b/V4.py index 161360d..fea8fd5 100755 --- a/V4.py +++ b/V4.py @@ -130,6 +130,13 @@ def update_row(compte, points, mycursor, mydb): printf(mycursor.rowcount, "record(s) updated") +def update_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") + + def get_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 if same_points : mycursor.execute(f"SELECT * FROM daily WHERE points = {points} AND compte = '{compte}' AND date = current_date() ;") @@ -156,6 +163,8 @@ def add_to_database(compte, points): else : # if the row don't exist, create it with the good ammount of points add_row(compte, points,mycursor,mydb) printf("row added") + if points > 10 : + update_last(compte, points, mycursor, mydb) mycursor.close() mydb.close()