def get_user(user: User): request = DBRequest() data = RequestsHelper.get_user(user, request) request.close() return data
def create_status(user: User, start_status): request = DBRequest() RequestsHelper.create_status(request, user, start_status) request.complete() request.close()
def update_password(user: User): request = DBRequest() RequestsHelper.update_password(user, request) request.complete() request.close()
def delete_user(user: User): request = DBRequest() RequestsHelper.delete_user(user, request) request.complete() request.close()
def update_name(user: User): request = DBRequest() RequestsHelper.update_uname(user, request) request.complete() request.close()
def set_tabnr(user: User): request = DBRequest() RequestsHelper.set_tabnr(request, user) request.complete() request.close()
def insert_user_v2(user: User): request = DBRequest() RequestsHelper.insert_user_v2(user, request) request.complete() request.close()
def change_status(user: User, new_status): request = DBRequest() RequestsHelper.change_status(request, user, new_status) request.complete() request.close()
def get_all_users(): request = DBRequest() data = RequestsHelper.get_all_users(request) request.complete() request.close() return data
def get_status(user: User): request = DBRequest() status = RequestsHelper.get_status(user) request.complete() request.close() return status
def check_password(user: User): request = DBRequest() data = RequestsHelper.get_user(user, request) request.complete() request.close() # Здесь добавить проверку на корректность пароля if not data[0][2]: return False return True
def get_user(user: User, request: DBRequest): cursor = request.get_cursor() cursor.execute(f"SELECT * FROM users WHERE _id = '{user.get_id()}'") return cursor.fetchall()
def change_status(request: DBRequest, user: User, new_status): cursor = request.get_cursor() cursor.execute( f"UPDATE user_statuses SET status = '{new_status}' WHERE _id = '{user.get_id()}'" )
def create_status(request: DBRequest, user: User, start_status): cursor = request.get_cursor() cursor.execute( f"INSERT INTO user_statuses VALUES('{user.get_id()}', '{start_status}')" )
def get_all_users(request: DBRequest): cursor = request.get_cursor() cursor.execute(f"SELECT * FROM users") return cursor.fetchall()
def delete_user(user: User, request: DBRequest): cursor = request.get_cursor() cursor.execute(f"DELETE FROM users WHERE _id = '{user.get_id()}'")
def update_password(user: User, request: DBRequest): cursor = request.get_cursor() cursor.execute( f"UPDATE users SET password = '******' WHERE _id = '{user.get_id()}'" )
def update_uname(user: User, request: DBRequest): cursor = request.get_cursor() cursor.execute( f"UPDATE users SET uname = '{user.get_uname()}' WHERE _id = '{user.get_id()}'" )
def set_tabnr(request: DBRequest, user: User): cursor = request.get_cursor() cursor.execute( f"UPDATE users SET tabnr = '{user.get_tabnr()}' WHERE _id = '{user.get_id()}'" )
def get_status(request: DBRequest, user: User): cursor = request.get_cursor() cursor.execute( f"SELECT status FROM user_statuses WHERE _id = '{user.get_id()}'")
def insert_user_v2(user: User, request: DBRequest): cursor = request.get_cursor() cursor.execute( f"INSERT INTO users VALUES ('{user.get_id()}', '{user.get_uname()}', '{user.get_password()}', '{user.get_tabnr()}')" )