fixed things, like auto adding account to database

This commit is contained in:
piair
2023-08-25 19:40:39 +02:00
parent 820efd8126
commit 6efc77c512
3 changed files with 12 additions and 8 deletions

View File

@ -18,8 +18,14 @@ def update_row(compte, points, mycursor, mydb):
# update the value of last_pts for the table comptes
def update_last(compte, points, mycursor, mydb):
sql = f"UPDATE comptes SET last_pts = {points} WHERE compte = '{compte}';"
mycursor.execute(sql)
sql1 = f"UPDATE comptes SET last_pts = {points} WHERE compte = '{compte}';"
sql2 = f"select * from comptes where nom = '{compte}'"
sql3 = "INSERT INTO comptes (compte, last_pts,banned) VALUES ('{compte}', {points}, 0)"
cmd = mycursor.execute(sql2)
if len(list(cmd)) == 0:
mycursor.execute(sql3)
else :
mycursor.execute(sql1)
mydb.commit()
#printf(mycursor.rowcount, "record(s) updated")