def update_dl1a(self, id_dl1a, subrun_number=None, dl1a_path_file=None): try: dl1a_before: Dl1aDto = self.get_dl1a_by_id(id_dl1a) if Checkers.validate_int( id_dl1a, LstDl1a.id_dl1a) and dl1a_before.id_dl1a is not None: self.__session.query(LstDl1a).filter(LstDl1a.id_dl1a.like(id_dl1a)) \ .update({ LstDl1a.subrun_number: Checkers.check_field_not_null(LstDl1a.subrun_number, subrun_number), LstDl1a.dl1a_path_file: Checkers.check_field_not_null(LstDl1a.dl1a_path_file, dl1a_path_file) }, synchronize_session=False ) self.__session.commit() dl1a_after: Dl1aDto = self.get_dl1a_by_id(id_dl1a) if dl1a_before.__dict__ != dl1a_after.__dict__: print("RECORD UPDATE IN TABLE '{}' WITH ID '{}'".format( LstDl1a.__tablename__.name, id_dl1a)) else: print(" THE RECORD OF TABLE '{}' HAS NOT BEEN UPDATED". format(LstDl1a.__tablename__.name)) else: print(" THE RECORD OF TABLE '{}' COULD NOT BE UPDATED ".format( LstDl1a.__tablename__.name)) except (InvalidRequestError, NameError) as error_request: Checkers.print_exception_one_param(error_request) except OperationalError as error_request2: Checkers.print_exception_two_params(error_request2.orig.args[1], error_request2.orig.args[0])
def update_pixel_info(self, pixel_id_to_search, pixel_group_number_to_search, pixel_id_to_update=None, pixel_group_number_to_update=None, pixel_pos_x=None, pixel_pos_y=None, pixel_pos_z=None): try: pixel_info_before: PixelInformationDto = self.get_pixel_info_by_id( pixel_id_to_search, pixel_group_number_to_search) if Checkers.validate_int( pixel_id_to_search, LstPixelInformation.pixel_id.name ) and Checkers.validate_int( pixel_group_number_to_search, LstPixelInformation.pixel_group_number.name ) and pixel_info_before.pixel_id is not None and pixel_info_before.pixel_group_number is not None: self.__session.query(LstPixelInformation).filter(LstPixelInformation.pixel_id.like(pixel_id_to_search), LstPixelInformation.pixel_group_number.like( pixel_group_number_to_search)) \ .update({ LstPixelInformation.pixel_id_to_update: Checkers.check_field_not_null( LstPixelInformation.pixel_id_to_update, pixel_id_to_update), LstPixelInformation.pixel_group_number_to_update: Checkers.check_field_not_null( LstPixelInformation.pixel_group_number_to_update, pixel_group_number_to_update), LstPixelInformation.pixel_pos_x: Checkers.check_field_not_null(LstPixelInformation.pixel_pos_x, pixel_pos_x), LstPixelInformation.pixel_pos_y: Checkers.check_field_not_null(LstPixelInformation.pixel_pos_y, pixel_pos_y), LstPixelInformation.pixel_pos_z: Checkers.check_field_not_null(LstPixelInformation.pixel_pos_z, pixel_pos_z) }, synchronize_session=False ) self.__session.commit() pixel_info_after: PixelInformationDto = self.get_pixel_info_by_id( pixel_id_to_search, pixel_group_number_to_search) if pixel_info_before.__dict__ != pixel_info_after.__dict__: print("RECORD UPDATE IN TABLE '{}' WITH PIXEL_ID '{}'". format(LstPixelInformation.__tablename__.name, pixel_id_to_search)) else: print(" THE RECORD OF TABLE '{}' HAS NOT BEEN UPDATED". format(LstPixelInformation.__tablename__.name)) else: print(" THE RECORD OF TABLE '{}' COULD NOT BE UPDATED ".format( LstPixelInformation.__tablename__.name)) except (InvalidRequestError, NameError) as error_request: Checkers.print_exception_one_param(error_request) except OperationalError as error_request2: Checkers.print_exception_two_params(error_request2.orig.args[1], error_request2.orig.args[0])
def update_r1_data_check_specific(self, id_r1_data_check_specific, init_event=None, end_event=None, init_pixel=None, end_pixel=None, init_sample=None, end_sample=None, init_subrun=None, end_subrun=None, type_of_gap_calc=None, list_of_module_in_detail=None): try: r1_before: R1DataCheckSpecificDto = self.get_r1_data_check_specific_by_id(id_r1_data_check_specific) if Checkers.validate_int(id_r1_data_check_specific, LstR1DataCheckSpecific.id_r1_data_check_specific.name) and r1_before.id_r1_data_check_specific is not None: self.__session.query(LstR1DataCheckSpecific).filter( LstR1DataCheckSpecific.id_r1_data_check_specific.like(id_r1_data_check_specific)) \ .update({ LstR1DataCheckSpecific.init_event: Checkers.check_field_not_null(LstR1DataCheckSpecific.init_event, init_event), LstR1DataCheckSpecific.end_event: Checkers.check_field_not_null(LstR1DataCheckSpecific.end_event, end_event), LstR1DataCheckSpecific.init_pixel: Checkers.check_field_not_null(LstR1DataCheckSpecific.init_pixel, init_pixel), LstR1DataCheckSpecific.end_pixel: Checkers.check_field_not_null(LstR1DataCheckSpecific.end_pixel, end_pixel), LstR1DataCheckSpecific.init_sample: Checkers.check_field_not_null( LstR1DataCheckSpecific.init_sample, init_sample), LstR1DataCheckSpecific.end_sample: Checkers.check_field_not_null(LstR1DataCheckSpecific.end_sample, end_sample), LstR1DataCheckSpecific.init_subrun: Checkers.check_field_not_null( LstR1DataCheckSpecific.init_subrun, init_subrun), LstR1DataCheckSpecific.end_subrun: Checkers.check_field_not_null(LstR1DataCheckSpecific.end_subrun, end_subrun), LstR1DataCheckSpecific.type_of_gap_calc: Checkers.check_field_not_null( LstR1DataCheckSpecific.type_of_gap_calc, type_of_gap_calc), LstR1DataCheckSpecific.list_of_module_in_detail: Checkers.check_field_not_null( LstR1DataCheckSpecific.list_of_module_in_detail, list_of_module_in_detail) }, synchronize_session=False ) self.__session.commit() r1_after: R1DataCheckSpecificDto = self.get_r1_data_check_specific_by_id(id_r1_data_check_specific) if r1_before.__dict__ != r1_after.__dict__: print("RECORD UPDATE IN TABLE '{}' WITH ID '{}'".format(LstR1DataCheckSpecific.__tablename__.name, id_r1_data_check_specific)) else: print(" THE RECORD OF TABLE '{}' HAS NOT BEEN UPDATED".format( LstR1DataCheckSpecific.__tablename__.name)) else: print( " THE RECORD OF TABLE '{}' COULD NOT BE UPDATED ".format(LstR1DataCheckSpecific.__tablename__.name)) except (InvalidRequestError, NameError) as error_request: Checkers.print_exception_one_param(error_request) except OperationalError as error_request2: Checkers.print_exception_two_params(error_request2.orig.args[1], error_request2.orig.args[0])
def update_r1_data_check_plot(self, id_record, id_lst_r1_data_check_plot_to_search, id_lst_r1_data_check_plot_to_update=None, id_r1_data_check=None, lst_r1_data_check_plot_path=None, lst_r1_data_check_plot_description=None): try: r1_before: R1DataCheckPlotDto = self.get_r1_data_check_plot_by_id( id_lst_r1_data_check_plot_to_search) if Checkers.validate_int( id_lst_r1_data_check_plot_to_search, LstR1DataCheckPlot.id_lst_r1_data_check_plot.name ) and r1_before.id_record is not None and r1_before.id_lst_r1_data_check_plot is not None: self.__session.query(LstR1DataCheckPlot).filter(LstR1DataCheckPlot.id_record.like(id_record)) \ .filter(LstR1DataCheckPlot.id_lst_r1_data_check_plot.like(id_lst_r1_data_check_plot_to_search)) \ .update({ LstR1DataCheckPlot.id_lst_r1_data_check_plot: Checkers.check_field_not_null( LstR1DataCheckPlot.id_lst_r1_data_check_plot, id_lst_r1_data_check_plot_to_update), LstR1DataCheckPlot.id_r1_data_check: Checkers.check_field_not_null( LstR1DataCheckPlot.id_r1_data_check, id_r1_data_check), LstR1DataCheckPlot.lst_r1_data_check_plot_path: Checkers.check_field_not_null( LstR1DataCheckPlot.lst_r1_data_check_plot_path, lst_r1_data_check_plot_path), LstR1DataCheckPlot.lst_r1_data_check_plot_description: Checkers.check_field_not_null( LstR1DataCheckPlot.lst_r1_data_check_plot_description, lst_r1_data_check_plot_description) }, synchronize_session=False ) self.__session.commit() r1_after: R1DataCheckPlotDto = self.get_r1_data_check_plot_by_id( id_lst_r1_data_check_plot_to_search) if r1_before.__dict__ != r1_after.__dict__: print("RECORD UPDATE IN TABLE '{}' WITH ID '{}'".format( LstR1DataCheckPlot.__tablename__.name, id_record)) else: print(" THE RECORD OF TABLE '{}' HAS NOT BEEN UPDATED". format(LstR1DataCheckPlot.__tablename__.name)) else: print(" THE RECORD OF TABLE '{}' COULD NOT BE UPDATED ".format( LstR1DataCheckPlot.__tablename__.name)) except (InvalidRequestError, NameError) as error_request: Checkers.print_exception_one_param(error_request) except OperationalError as error_request2: Checkers.print_exception_two_params(error_request2.orig.args[1], error_request2.orig.args[0])
def update_dates(self, date_to_serach, id_date, date_to_update=None): try: date_before: DatesDto = self.get_date_by_id(id_date) if Checkers.validate_int( id_date, LstDates.id_date.name ) and Checkers.validate_datetime( date_to_serach, LstDates.date ) and date_before.id_date is not None and date_before.date is not None: self.__session.query(LstDates).filter(LstDates.date.like(date_to_serach), LstDates.id_date.like(id_date)) \ .update({ LstDates.date: Checkers.check_field_not_null(LstDates.date, date_to_update)}, synchronize_session=False ) self.__session.commit() date_after: DatesDto = self.get_date_by_id(id_date) if date_before.__dict__ != date_after.__dict__: print("RECORD UPDATE IN TABLE '{}' WITH ID '{}'".format( LstDates.__tablename__.name, id_date)) else: print(" THE RECORD OF TABLE '{}' HAS NOT BEEN UPDATED". format(LstDates.__tablename__.name)) else: print(" THE RECORD OF TABLE '{}' COULD NOT BE UPDATED ".format( LstDates.__tablename__.name)) except (InvalidRequestError, NameError) as error_request: Checkers.print_exception_one_param(error_request) except OperationalError as error_request2: Checkers.print_exception_two_params(error_request2.orig.args[1], error_request2.orig.args[0])
def update_run_type(self, id_run_type, description_run_type=None): try: run_type_before: RunTypeDto = self.get_run_type_by_id(id_run_type) if Checkers.validate_int(id_run_type, LstRunType.id_run_type.name) and run_type_before.id_run_type is not None: self.__session.query(LstRunType).filter(LstRunType.id_run_type.like(id_run_type)) \ .update({ LstRunType.description_run_type: Checkers.check_field_not_null(LstRunType.description_run_type, description_run_type) }, synchronize_session=False ) self.__session.commit() run_type_after: RunTypeDto = self.get_run_type_by_id(id_run_type) if run_type_before.__dict__ != run_type_after.__dict__: print(" RECORD UPDATED IN TABLE '{}' WITH ID '{}' ".format(LstRunType.__tablename__.name, id_run_type)) else: print(" THE RECORD OF TABLE '{}' HAS NOT BEEN UPDATED".format(LstRunType.__tablename__.name)) else: print(" THE RECORD OF TABLE '{}' COULD NOT BE UPDATED ".format(LstRunType.__tablename__.name)) except (InvalidRequestError, NameError) as error_request: Checkers.print_exception_one_param(error_request) except OperationalError as error_request2: Checkers.print_exception_two_params(error_request2.orig.args[1], error_request2.orig.args[0])
def update_r1_data_check_analysis(self, id_r1_data_check_to_search, id_r1_data_check_to_update=None, run_number=None, id_r1_data_check_specific=None): try: r1_before: R1DataCheckAnalysisDto = self.get_r1_data_check_analysis_by_id( id_r1_data_check_to_search) if Checkers.validate_int( id_r1_data_check_to_search, LstR1DataCheckAnalysis.id_r1_data_check.name ) and r1_before.id_r1_data_check is not None: self.__session.query(LstR1DataCheckAnalysis) \ .filter(LstR1DataCheckAnalysis.id_r1_data_check.like(id_r1_data_check_to_search)) \ .update({ LstR1DataCheckAnalysis.id_r1_data_check: Checkers.check_field_not_null( LstR1DataCheckAnalysis.id_r1_data_check, id_r1_data_check_to_update), LstR1DataCheckAnalysis.run_number: Checkers.check_field_not_null(LstR1DataCheckAnalysis.run_number, run_number), LstR1DataCheckAnalysis.id_r1_data_check_specific: Checkers.check_field_not_null( LstR1DataCheckAnalysis.id_r1_data_check_specific, id_r1_data_check_specific) }, synchronize_session=False ) self.__session.commit() r1_after: R1DataCheckAnalysisDto = self.get_r1_data_check_analysis_by_id( id_r1_data_check_to_search) if r1_before.__dict__ != r1_after.__dict__: print("RECORD UPDATE IN TABLE '{}' WITH ID '{}'".format( LstR1DataCheckAnalysis.__tablename__.name, id_r1_data_check_to_search)) else: print(" THE RECORD OF TABLE '{}' HAS NOT BEEN UPDATED". format(LstR1DataCheckAnalysis.__tablename__.name)) else: print(" THE RECORD OF TABLE '{}' COULD NOT BE UPDATED ".format( LstR1DataCheckAnalysis.__tablename__.name)) except (InvalidRequestError, NameError) as error_request: Checkers.print_exception_one_param(error_request) except OperationalError as error_request2: Checkers.print_exception_two_params(error_request2.orig.args[1], error_request2.orig.args[0])
def update_qp_data(self, id_qp_data, pixel_id=None, id_dl1a=None, q_average=None, q_rms=None, time_average=None, time_rms=None, dl1a_check_build=None): try: qp_before: QpDataDto = self.get_qp_data_by_id(id_qp_data) if Checkers.validate_int(id_qp_data, LstQpData.id_qp_data.name) and qp_before.id_qp_data is not None: self.__session.query(LstQpData).filter(LstQpData.id_qp_data.like(id_qp_data)) \ .update({ LstQpData.pixel_id: Checkers.check_field_not_null(LstQpData.pixel_id, pixel_id), LstQpData.id_dl1a: Checkers.check_field_not_null(LstQpData.id_dl1a, id_dl1a), LstQpData.q_average: Checkers.check_field_not_null(LstQpData.q_average, q_average), LstQpData.q_rms: Checkers.check_field_not_null(LstQpData.q_rms, q_rms), LstQpData.time_average: Checkers.check_field_not_null(LstQpData.time_average, time_average), LstQpData.time_rms: Checkers.check_field_not_null(LstQpData.time_rms, time_rms), LstQpData.dl1a_check_build: Checkers.check_field_not_null(LstQpData.dl1a_check_build, dl1a_check_build) }, synchronize_session=False ) self.__session.commit() qp_after: QpDataDto = self.get_qp_data_by_id(id_qp_data) if qp_before.__dict__ != qp_after.__dict__: print("RECORD UPDATE IN TABLE '{}' WITH ID '{}'".format(LstQpData.__tablename__.name, id_qp_data)) else: print(" THE RECORD OF TABLE '{}' HAS NOT BEEN UPDATED".format(LstQpData.__tablename__.name)) else: print(" THE RECORD OF TABLE '{}' COULD NOT BE UPDATED ".format(LstQpData.__tablename__.name)) except (InvalidRequestError, NameError) as error_request: Checkers.print_exception_one_param(error_request) except OperationalError as error_request2: Checkers.print_exception_two_params(error_request2.orig.args[1], error_request2.orig.args[0])
def update_pixel_group(self, id_config, pixel_group_number_to_search, pixel_group_number_to_update=None, id_pixel_group=None, other_data=None): try: pixel_group_before: PixelGroupDto = self.__pixel_group_by_id( pixel_group_number_to_search, id_config) if Checkers.validate_int( id_config, LstPixelGroup.id_config.name ) and Checkers.validate_int( pixel_group_number_to_search, LstPixelGroup.pixel_group_number.name ) and pixel_group_before.id_config is not None and pixel_group_before.pixel_group_number is not None: self.__session.query(LstPixelGroup).filter(LstPixelGroup.id_config.like(id_config), LstPixelGroup.pixel_group_number.like( pixel_group_number_to_search)) \ .update({ LstPixelGroup.pixel_group_number_to_update: Checkers.check_field_not_null( LstPixelGroup.pixel_group_number_to_update, pixel_group_number_to_update), LstPixelGroup.id_config: Checkers.check_field_not_null(LstPixelGroup.id_config, id_config), LstPixelGroup.other_data: Checkers.check_field_not_null(LstPixelGroup.other_data, other_data) }, synchronize_session=False ) self.__session.commit() pixel_group_after: PixelGroupDto = self.get_pixel_group_by_id( pixel_group_number_to_search, id_config) if pixel_group_before.__dict__ != pixel_group_after.__dict__: print("RECORD UPDATE IN TABLE '{}' WITH ID '{}'".format( LstPixelGroup.__tablename__.name, id_pixel_group)) else: print(" THE RECORD OF TABLE '{}' HAS NOT BEEN UPDATED". format(LstPixelGroup.__tablename__.name)) else: print(" THE RECORD OF TABLE '{}' COULD NOT BE UPDATED ".format( LstPixelGroup.__tablename__.name)) except (InvalidRequestError, NameError) as error_request: Checkers.print_exception_one_param(error_request) except OperationalError as error_request2: Checkers.print_exception_two_params(error_request2.orig.args[1], error_request2.orig.args[0])
def update_analysis_eval(self, id_analysis_evaluation, id_lst_r1_data_check_plot=None, parameter_description=None, parameter_value=None): try: analysis_dto_before: AnalysisEvaluationDto = self.get_analysis_by_id( id_analysis_evaluation) if Checkers.validate_int( id_analysis_evaluation, LstAnalysisEvaluation.id_analysis_evaluation ) and analysis_dto_before.id_analysis_evaluation is not None: self.__session.query(LstAnalysisEvaluation).filter( LstAnalysisEvaluation.id_analysis_evaluation.like(id_analysis_evaluation)) \ .update({ LstAnalysisEvaluation.id_lst_r1_data_check_plot: Checkers.check_field_not_null( LstAnalysisEvaluation.id_lst_r1_data_check_plot, id_lst_r1_data_check_plot), LstAnalysisEvaluation.parameter_description: Checkers.check_field_not_null( LstAnalysisEvaluation.parameter_description, parameter_description), LstAnalysisEvaluation.parameter_value: Checkers.check_field_not_null( LstAnalysisEvaluation.parameter_value, parameter_value)}, synchronize_session=False ) self.__session.commit() analysis_dto_after: AnalysisEvaluationDto = self.get_analysis_by_id( id_analysis_evaluation) if analysis_dto_before.__dict__ != analysis_dto_after.__dict__: print("RECORD UPDATE IN TABLE '{}' WITH ID '{}'".format( LstAnalysisEvaluation.__tablename__.name, id_analysis_evaluation)) else: print(" THE RECORD OF TABLE '{}' HAS NOT BEEN UPDATED". format(LstAnalysisEvaluation.__tablename__.name)) else: print(" THE RECORD OF TABLE '{}' COULD NOT BE UPDATED ".format( LstAnalysisEvaluation.__tablename__.name)) except (InvalidRequestError, NameError) as error_request: Checkers.print_exception_one_param(error_request) except OperationalError as error_request2: Checkers.print_exception_two_params(error_request2.orig.args[1], error_request2.orig.args[0])
def update_files_of_subrun(self, id_file_subrun, subrun_number=None, path_file=None, num_events=None, array_num_files=None): try: files_before: FilesOfSubrunDto = self.__files_by_id(id_file_subrun) if Checkers.validate_int( id_file_subrun, LstFilesOfSubrun.id_file_subrun.name ) and files_before.id_file_subrun is not None: self.__session.query(LstFilesOfSubrun).filter(LstFilesOfSubrun.id_file_subrun.like(id_file_subrun)) \ .update({ LstFilesOfSubrun.subrun_number: Checkers.check_field_not_null(LstFilesOfSubrun.subrun_number, subrun_number), LstFilesOfSubrun.path_file: Checkers.check_field_not_null(LstFilesOfSubrun.path_file, path_file), LstFilesOfSubrun.num_events: Checkers.check_field_not_null(LstFilesOfSubrun.num_events, num_events), LstFilesOfSubrun.array_num_files: Checkers.check_field_not_null(LstFilesOfSubrun.array_num_files, array_num_files) }, synchronize_session=False ) self.__session.commit() files_after: FilesOfSubrunDto = self.__files_by_id( id_file_subrun) if files_before.__dict__ != files_after.__dict__: print("RECORD UPDATE IN TABLE '{}' WITH ID '{}'".format( LstFilesOfSubrun.__tablename__.name, id_file_subrun)) else: print(" THE RECORD OF TABLE '{}' HAS NOT BEEN UPDATED". format(LstFilesOfSubrun.__tablename__.name)) else: print(" THE RECORD OF TABLE '{}' COULD NOT BE UPDATED ".format( LstFilesOfSubrun.__tablename__.name)) except (InvalidRequestError, NameError) as error_request: Checkers.print_exception_one_param(error_request) except OperationalError as error_request2: Checkers.print_exception_two_params(error_request2.orig.args[1], error_request2.orig.args[0])
def update_config(self, id_to_update, config_description=None, param_1=None, param_2=None, param_3=None): try: config_to_update_before: ConfigurationDto = self.get_config_by_id( id_to_update) if Checkers.validate_int( id_to_update, LstConfiguration.id_config.name ) and config_to_update_before.id_config is not None: self.__session.query(LstConfiguration).filter(LstConfiguration.id_config.like(id_to_update)) \ .update({ LstConfiguration.config_description: Checkers.check_field_not_null( LstConfiguration.config_description, config_description), LstConfiguration.param_1: Checkers.check_field_not_null(LstConfiguration.param_1, param_1), LstConfiguration.param_2: Checkers.check_field_not_null(LstConfiguration.param_2, param_2), LstConfiguration.param_3: Checkers.check_field_not_null(LstConfiguration.param_3, param_3)}, synchronize_session=False ) self.__session.commit() config_to_update_after: ConfigurationDto = self.get_config_by_id( id_to_update) if config_to_update_before.__dict__ != config_to_update_after.__dict__: print(" RECORD UPDATED IN TABLE '{}' WITH ID '{}' ".format( LstConfiguration.__tablename__.name, id_to_update)) else: print(" THE RECORD OF TABLE '{}' HAS NOT BEEN UPDATED". format(LstConfiguration.__tablename__.name)) else: print(" THE RECORD OF TABLE '{}' COULD NOT BE UPDATED ".format( LstConfiguration.__tablename__.name)) except (InvalidRequestError, NameError) as error_request: Checkers.print_exception_one_param(error_request) except OperationalError as error_request2: Checkers.print_exception_two_params(error_request2.orig.args[1], error_request2.orig.args[0])
def update_subruns(self, id_subrun, subrun_number_to_search, subrun_number_to_update=None, run_number=None, id_run_type=None): try: subruns_before: SubrunsDto = self.get_subrun_by_id(id_subrun) if Checkers.validate_int( id_subrun, LstSubruns.id_subrun.name ) and subruns_before.id_subrun is not None: self.__session.query(LstSubruns).filter(LstSubruns.id_subrun.like(id_subrun)) \ .filter(LstSubruns.subrun_number.like(subrun_number_to_search)) \ .update({ LstSubruns.subrun_number: Checkers.check_field_not_null(LstSubruns.subrun_number, subrun_number_to_update), LstSubruns.run_number: Checkers.check_field_not_null(LstSubruns.run_number, run_number), LstSubruns.id_run_type: Checkers.check_field_not_null(LstSubruns.id_run_type, id_run_type) }, synchronize_session=False ) self.__session.commit() subruns_after: SubrunsDto = self.get_subrun_by_id(id_subrun) if subruns_before.__dict__ != subruns_after.__dict__: print("RECORD UPDATE IN TABLE '{}' WITH ID '{}'".format( LstSubruns.__tablename__.name, id_subrun)) else: print(" THE RECORD OF TABLE '{}' HAS NOT BEEN UPDATED". format(LstSubruns.__tablename__.name)) else: print(" THE RECORD OF TABLE '{}' COULD NOT BE UPDATED ".format( LstSubruns.__tablename__.name)) except (InvalidRequestError, NameError) as error_request: Checkers.print_exception_one_param(error_request) except OperationalError as error_request2: Checkers.print_exception_two_params(error_request2.orig.args[1], error_request2.orig.args[0])
def update_productions(self, id_production, run_number=None, id_run_type=None, r1_check_build=None, dl1a_check_build=None, dl1b_check_build=None, dl2_check_build=None, number_production=None): try: prod_before: ProductionsDto = self.get_productions_by_id(id_production) if Checkers.validate_int(id_production, LstProductions.id_production.name) and prod_before.id_production is not None: self.__session.query(LstProductions).filter(LstProductions.id_production.like(id_production)) \ .update({ LstProductions.run_number: Checkers.check_field_not_null(LstProductions.run_number, run_number), LstProductions.id_run_type: Checkers.check_field_not_null(LstProductions.id_run_type, id_run_type), LstProductions.r1_check_build: Checkers.check_field_not_null(LstProductions.r1_check_build, r1_check_build), LstProductions.dl1a_check_build: Checkers.check_field_not_null(LstProductions.dl1a_check_build, dl1a_check_build), LstProductions.dl1b_check_build: Checkers.check_field_not_null(LstProductions.dl1b_check_build, dl1b_check_build), LstProductions.dl2_check_build: Checkers.check_field_not_null(LstProductions.dl2_check_build, dl2_check_build), LstProductions.number_production: Checkers.check_field_not_null(LstProductions.number_production, number_production) }, synchronize_session=False ) self.__session.commit() prod_after: ProductionsDto = self.get_productions_by_id(id_production) if prod_before.__dict__ != prod_after.__dict__: print("RECORD UPDATE IN TABLE '{}' WITH ID '{}'".format(LstProductions.__tablename__.name, id_production)) else: print(" THE RECORD OF TABLE '{}' HAS NOT BEEN UPDATED".format(LstProductions.__tablename__.name)) else: print(" THE RECORD OF TABLE '{}' COULD NOT BE UPDATED ".format(LstProductions.__tablename__.name)) except (InvalidRequestError, NameError) as error_request: Checkers.print_exception_one_param(error_request) except OperationalError as error_request2: Checkers.print_exception_two_params(error_request2.orig.args[1], error_request2.orig.args[0])
def update_runs(self, id_run, run_number=None, id_run_type=None, date=None, id_config=None, id_production=None, path_file=None, init_ra=None, end_ra=None, init_dec=None, end_dec=None, init_altitude=None, end_altitude=None, init_azimuth=None, end_azimuth=None, init_time_collect_data=None, end_time_collect_data=None): try: runs_before: RunsDto = self.get_runs_by_id(id_run) if Checkers.validate_int( id_run, LstRuns.id_run.name) and runs_before.id_run is not None: self.__session.query(LstRuns).filter(LstRuns.id_run.like(id_run)) \ .update({ LstRuns.run_number: Checkers.check_field_not_null(LstRuns.run_number, run_number), LstRuns.id_run_type: Checkers.check_field_not_null(LstRuns.id_run_type, id_run_type), LstRuns.date: Checkers.check_field_not_null(LstRuns.date, date), LstRuns.id_config: Checkers.check_field_not_null(LstRuns.id_config, id_config), LstRuns.id_production: Checkers.check_field_not_null(LstRuns.id_production, id_production), LstRuns.path_file: Checkers.check_field_not_null(LstRuns.path_file, path_file), LstRuns.init_ra: Checkers.check_field_not_null(LstRuns.init_ra, init_ra), LstRuns.end_ra: Checkers.check_field_not_null(LstRuns.end_ra, end_ra), LstRuns.init_dec: Checkers.check_field_not_null(LstRuns.init_dec, init_dec), LstRuns.end_dec: Checkers.check_field_not_null(LstRuns.end_dec, end_dec), LstRuns.init_altitude: Checkers.check_field_not_null(LstRuns.init_altitude, init_altitude), LstRuns.end_altitude: Checkers.check_field_not_null(LstRuns.end_altitude, end_altitude), LstRuns.init_azimuth: Checkers.check_field_not_null(LstRuns.init_azimuth, init_azimuth), LstRuns.end_azimuth: Checkers.check_field_not_null(LstRuns.end_azimuth, end_azimuth), LstRuns.init_time_collect_data: Checkers.check_field_not_null(LstRuns.init_time_collect_data, init_time_collect_data), LstRuns.end_time_collect_data: Checkers.check_field_not_null(LstRuns.end_time_collect_data, end_time_collect_data) }, synchronize_session=False ) self.__session.commit() runs_after: RunsDto = self.get_runs_by_id(id_run) if runs_before.__dict__ != runs_after.__dict__: print("RECORD UPDATE IN TABLE '{}' WITH ID '{}'".format( LstRuns.__tablename__.name, id_run)) else: print(" THE RECORD OF TABLE '{}' HAS NOT BEEN UPDATED". format(LstRuns.__tablename__.name)) else: print(" THE RECORD OF TABLE '{}' COULD NOT BE UPDATED ".format( LstRuns.__tablename__.name)) except (InvalidRequestError, NameError) as error_request: Checkers.print_exception_one_param(error_request) except OperationalError as error_request2: Checkers.print_exception_two_params(error_request2.orig.args[1], error_request2.orig.args[0])