def upload_schools(data): all_schools = [] for row in data: school = {"school_name": row["school"]} all_schools.append(school) db_session.bulk_insert_mappings(School, all_schools, return_defaults=True) db_session.commit()
def upload_study_options(data): all_study_options = [] for row in data: study_option = {"study_option": row["study_option"]} all_study_options.append(study_option) db_session.bulk_insert_mappings( StudyOption, all_study_options, return_defaults=True ) db_session.commit()
def upload_skills(data): all_skills = [] for row in data: study_option = StudyOption.query.filter_by( study_option=row["study_option"] ).first() list_of_skills = row["skills"].split(",") for skill in list_of_skills: each_skill = {"study_option_id": study_option.id, "skill": skill} all_skills.append(each_skill) db_session.bulk_insert_mappings(Skill, all_skills, return_defaults=True) db_session.commit()
def upload_courses(num): course_data = generate_course_data(num) db_session.bulk_insert_mappings(Course, course_data, return_defaults=True) db_session.commit()
def upload_skills_relations(num): relation_data = generate_skills_relations(num) db_session.bulk_insert_mappings(SkillRelation, relation_data, return_defaults=True) db_session.commit()