From de5fc08a8c564b462e4dc15eb5127cf428e9339d Mon Sep 17 00:00:00 2001 From: ctmbl Date: Sat, 31 Aug 2024 19:48:21 +0200 Subject: [PATCH] Move sql query for has_user to db_structure.py --- src/database/db_manager.py | 3 ++- src/database/db_structure.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/database/db_manager.py b/src/database/db_manager.py index 6ee6d26..9df5511 100644 --- a/src/database/db_manager.py +++ b/src/database/db_manager.py @@ -7,6 +7,7 @@ sql_add_user, sql_get_user, sql_get_users, + sql_has_user, ) from classes import User from classes import Challenge @@ -72,7 +73,7 @@ async def add_user(self, idx): def has_user(self, idx): cur = self.db.cursor() - res = cur.execute("SELECT * FROM users WHERE id=(?)", (idx,)).fetchone() + res = cur.execute(sql_has_user, (idx, )).fetchone() cur.close() return res is not None diff --git a/src/database/db_structure.py b/src/database/db_structure.py index 3e941dd..0095536 100644 --- a/src/database/db_structure.py +++ b/src/database/db_structure.py @@ -14,3 +14,6 @@ sql_get_users = """SELECT * FROM users;""" + + +sql_has_user = """SELECT * FROM users WHERE id=(?)"""