From 74850ed77b94f4114c7050d47541a5555db74fc0 Mon Sep 17 00:00:00 2001 From: 2000-Trek Date: Wed, 21 Jun 2023 23:00:22 +0200 Subject: [PATCH] Added cheks to make shure there is no SQLite error --- main.py | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/main.py b/main.py index 44fb6ef..c3cba4a 100644 --- a/main.py +++ b/main.py @@ -117,6 +117,7 @@ def remove_user(): return f'

Deleted user {user_name}

return to the tags and user list' else: return "Error: 043" + @app.route("/adduser/user", methods=['GET']) def adduser(): user = request.args.get("username") @@ -132,34 +133,25 @@ def adduser(): @app.route("/change", methods=['GET']) def change(): - user_id = int(request.args.get("id")) try: + user_id = int(request.args.get("id")) change = int(request.args.get("change")) except ValueError: return '

Error: 095

tags and user list' - c.execute(f"UPDATE users SET balance = balance + {change} WHERE id={user_id}") - socketio.emit("update", "update") - return """ - - - - """ - #socketio.emit("update", "update") - #conn.commit() - #if change < 0: - # text = "removed from" - # change_text = change * -1 - #elif change > 0: - # text = "added to" - # change_text = change - #elif change == 0: - # return "

Nothing was done!

" - #c.execute(f"SELECT * FROM users WHERE id={user_id}") - #user = c.fetchall()[0][1] - #return f'

{change_text} was {text} {user}

back to the list' - + c.execute(f"SELCET * FROM users WHERE id={user_id}") + if c.fetchall != []: + c.execute(f"UPDATE users SET balance = balance + {change} WHERE id={user_id}") + socketio.emit("update", "update") + return """ + + + + """ + else: + return "Error: 043" + @app.route("/addtag", methods=['GET']) def get_addtag_request(): global users