query = "INSERT INTO instrument_domains (instrument_id, domain) VALUES (%s, %s)" targetCursor.executemany(query, sourceCursor.fetchall()) targetConn.commit() print("Import instrument_domains: end") print("Import examination: start") sourceCursor.execute( """SELECT EXAMINATION_ID, CENTER_ID, COMMENT, DATE(EXAMINATION_DATE), GROUP_OF_SUBJECTS_ID, INVESTIGATOR_CENTER_ID, IS_INVESTIGATOR_EXTERNAL, INVESTIGATOR_ID, NOTE, STUDY_ID, SUBJECT_ID, SUBJECT_WEIGHT, TIMEPOINT_ID, REF_WEIGHT_UNIT_OF_MEASURE_ID FROM EXAMINATION""") bulk_insert( targetCursor, "examination", "id, center_id, comment, examination_date, experimental_group_of_subjects_id, investigator_center_id, investigator_external, investigator_id, note, study_id, subject_id, subject_weight, timepoint_id, weight_unit_of_measure", sourceCursor) targetConn.commit() print("Import examination: end") print("Import instrument_based_assessment: start") sourceCursor.execute( "SELECT INSTRUMENT_BASED_ASSESSMENT_ID, EXAMINATION_ID, INSTRUMENT_ID FROM INSTRUMENT_BASED_ASSESSMENT" ) query = "INSERT INTO instrument_based_assessment (id, examination_id, instrument_id) VALUES (%s, %s, %s)" targetCursor.executemany(query, sourceCursor.fetchall()) targetConn.commit()
query = "SET FOREIGN_KEY_CHECKS=0" targetCursor.execute(query) query = "SET UNIQUE_CHECKS=0" targetCursor.execute(query) query = "SET AUTOCOMMIT=0" targetCursor.execute(query) query = "SET SQL_LOG_BIN=0" targetCursor.execute(query) targetConn.commit() print("Import related_dataset: start") sourceCursor.execute("""SELECT STUDY_ID, DATASET_ID FROM REL_STUDY_DATASET""") bulk_insert(targetCursor, "related_datasets", """ study_id, dataset_id """, sourceCursor) targetConn.commit() print("Import related_dataset: end") query = "SET FOREIGN_KEY_CHECKS=1" targetCursor.execute(query) query = "SET UNIQUE_CHECKS=1" targetCursor.execute(query) query = "SET AUTOCOMMIT=1" targetCursor.execute(query) query = "SET SQL_LOG_BIN=1" targetCursor.execute(query) targetConn.commit()