-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcrud.py
51 lines (38 loc) · 1.31 KB
/
crud.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""File to handle interactions to the database"""
from database_model import Education, Experience, Skill, User, db
def create_user(name, phone, email, resume_order):
"""Create and return an user"""
user = User(name=name, phone=phone, email=email, resume_order=resume_order)
return user
def create_skill(name, proficiency, logo):
"""Create and return a skill"""
skill = Skill(name=name, proficiency=proficiency, logo=logo)
return skill
def create_experience(title, company, start_date, end_date, description, logo):
"""Create an return an experience"""
experience = Experience(
title=title,
company=company,
start_date=start_date,
end_date=end_date,
description=description,
logo=logo,
)
return experience
def create_education(course, school, start_date, end_date, grade, logo):
"""Create and return an education"""
education = Education(
course=course,
school=school,
start_date=start_date,
end_date=end_date,
grade=grade,
logo=logo,
)
return education
def get_all_education():
"""Return all educations"""
return Education.query.all()
def get_education_by_id(id):
"""Return an education based on id"""
return Education.query.filter(Education.id == id).first()