Ejemplo n.º 1
0
def delete_course(id):
    session = session_factory()
    session.query(Course)\
        .filter(Course.id == id)\
        .delete(synchronize_session='fetch')
    session.commit()
    session.close()
Ejemplo n.º 2
0
def delete_student(id):
    session = session_factory()
    session.query(Student)\
        .filter(Student.id == id)\
        .delete(synchronize_session='fetch')
    session.commit()
    session.close()
Ejemplo n.º 3
0
def update_course(newCourse):
    session = session_factory()
    course = session.query(Course).get(newCourse.id)
    course.update(newCourse)
    try:
        session.add(course)
        session.commit()
    except exc.IntegrityError:
        session.rollback()
    session.close()
Ejemplo n.º 4
0
def update_student(newStudent):
    session = session_factory()
    student = session.query(Student).get(newStudent.id)
    student.update(newStudent)
    try:
        session.add(student)
        session.commit()
    except exc.IntegrityError:
        session.rollback()
    session.close()
Ejemplo n.º 5
0
def create_student(student):
    session = session_factory()
    session.add(student)
    session.commit()
    session.close()
Ejemplo n.º 6
0
def get_course_by_id(id):
    session = session_factory()
    course = session.query(Course).get(id)
    session.close()
    return course
Ejemplo n.º 7
0
def create_course(course):
    session = session_factory()
    session.add(course)
    session.commit()
    session.close()
Ejemplo n.º 8
0
def get_student_by_id(id):
    session = session_factory()
    student = session.query(Student).get(id)
    session.close()
    return student