Skip to content

Commit

Permalink
Move sql query for has_user to db_structure.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ctmbl committed Aug 31, 2024
1 parent 6997ca9 commit de5fc08
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/database/db_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
sql_add_user,
sql_get_user,
sql_get_users,
sql_has_user,
)
from classes import User
from classes import Challenge
Expand Down Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions src/database/db_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@


sql_get_users = """SELECT * FROM users;"""


sql_has_user = """SELECT * FROM users WHERE id=(?)"""

0 comments on commit de5fc08

Please sign in to comment.