def get_user(user_id): cursor = connection.cursor() try: cursor.execute(dbqueries.get_user, [user_id]) results = DBManager.named_tuple_fetchall(cursor) if results is None: return None else: dict_user = results[0] user = Users() user.user_id = dict_user.USER_ID user.password = dict_user.PASSWORD user.email_address = dict_user.EMAIL_ADDRESS user.first_name = dict_user.FIRST_NAME user.last_name = dict_user.LAST_NAME user.is_admin = dict_user.IS_ADMIN return user except Exception as error: return None finally: cursor.close()
def authenticate_user(email_address, password): cursor = connection.cursor() try: cursor.execute(dbqueries.authenticate_user, [email_address, password]) results = DBManager.named_tuple_fetchall(cursor) if len(results) == 0: return None else: dict_user = results[0] print(dict_user) user = Users() user.user_id = dict_user.USER_ID user.password = dict_user.PASSWORD user.email_address = dict_user.EMAIL_ADDRESS user.first_name = dict_user.FIRST_NAME user.last_name = dict_user.LAST_NAME user.is_admin = dict_user.IS_ADMIN return user # except Exception as error: # return None finally: cursor.close()