fixes bug: setting user who is not present in pianist-table is no longer allowed

This commit is contained in:
2023-11-16 11:22:03 +01:00
parent fb13941756
commit 8db8deee79
2 changed files with 14 additions and 4 deletions

View File

@@ -23,9 +23,19 @@ class Session:
}
def set_user(self, arguments):
resultstring = ''
db_index = arguments[0]
self.user = db_index
return 'User set'
sql_command = f'''
SELECT *
FROM pianist
WHERE id = {db_index}
'''
if self.db_agent.execute(sql_command).fetchone():
self.user = db_index
resultstring += 'User set'
else:
resultstring += 'No such user'
return resultstring
def get_active_user(self):
sql_command = f'''