def delete_script(script_id): session = get_session() user_script = session.query(UserScript).filter( UserScript.id == script_id).first() session.delete(user_script) session.commit() session.close()
def get_user_steps_for_script(script_id): session = get_session() user_steps = session.query(UserStep) \ .filter_by(script_id=script_id) \ .order_by(UserStep.time_created.asc()) \ .all() session.close() return user_steps
def create_script_in_database(): current_date_time = datetime.now() script_name = current_date_time.strftime("%d-%m-%Y %H:%M") script = UserScript(name=script_name) session = get_session() session.add(script) session.commit() session.refresh(script) session.close() return script
def save_user_steps_in_database(user_steps): session = get_session() for user_step in user_steps: session.add(user_step) session.commit() session.close()
def get_user_steps(user_step_command_id): session = get_session() user_steps = session.query(UserStep).filter( UserStep.command_id == user_step_command_id).all() session.close() return user_steps
def delete_user_steps(user_step_command_id): session = get_session() session.query(UserStep).filter( UserStep.command_id == user_step_command_id).delete() session.commit() session.close()
def get_steps(): session = get_session() steps = session.query(Step).order_by(Step.name.asc()).all() session.close() return steps
def get_step_by_id(id): session = get_session() step = session.query(Step).filter_by(id=id).first() session.close() return step
def get_scripts(): session = get_session() scripts = session.query(UserScript).order_by(UserScript.id.desc()).all() session.close() return scripts
def update_script_name(script_id, script_name): session = get_session() script = session.query(UserScript).filter_by(id=script_id).first() script.name = script_name session.commit() session.close()