forked from piair/MsRewards-Reborn
Update db.py
This commit is contained in:
parent
ebb1a8e48f
commit
80286b6a05
@ -32,7 +32,8 @@ def get_row(compte, points, mycursor, same_points = True): #return if there is a
|
|||||||
return(len(myresult) == 1)
|
return(len(myresult) == 1)
|
||||||
|
|
||||||
|
|
||||||
def add_to_database(compte, points, sql_host,sql_usr,sql_pwd,sql_database ):
|
def add_to_database(compte, points, sql_host,sql_usr,sql_pwd,sql_database, save_if_fail=True):
|
||||||
|
try:
|
||||||
mydb = mysql.connector.connect(
|
mydb = mysql.connector.connect(
|
||||||
host=sql_host,
|
host=sql_host,
|
||||||
user=sql_usr,
|
user=sql_usr,
|
||||||
@ -57,5 +58,10 @@ def add_to_database(compte, points, sql_host,sql_usr,sql_pwd,sql_database ):
|
|||||||
|
|
||||||
mycursor.close()
|
mycursor.close()
|
||||||
mydb.close()
|
mydb.close()
|
||||||
|
except BaseException as e:
|
||||||
|
if save_if_fail:
|
||||||
|
print("\nLes points n'ont pas pu être ajoutés, enregistrement dans le fichier 'points.csv'\n")
|
||||||
|
with open("points.csv", "a") as file:
|
||||||
|
file.write(f"{compte},{points}\n")
|
||||||
|
raise e
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user