Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_user(self, username: str) -> models.User:
- file_path = self.create_db_path()
- with sql.connect(file_path) as mdb:
- cursor = mdb.cursor()
- srch = 'SELECT Password FROM Users WHERE Username=?'
- srch2 = 'SELECT Password FROM Passwords WHERE Username=?'
- try:
- user_results = cursor.execute(srch, (username, )).fetchone()
- if not user_results:
- return False
- password_results = cursor.execute(srch2, (username, )).fetchall()
- return_user = models.User(
- username = username,
- password = user_results[0],
- saved_passwords = password_results if password_results else []
- )
- if password_results:
- for password in password_results:
- return_user.saved_passwords.append(password[0])
- return return_user
- except Exception as e:
- raise e
- except sql.Error as err:
- raise err
Advertisement
Add Comment
Please, Sign In to add comment