forked from DevProjectsForDevOps/StudentCoursesRestAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
48 lines (36 loc) · 1.46 KB
/
models.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
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class Student(db.Model):
"""
Sample Student Table
"""
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(length=100), nullable=False)
email = db.Column(db.String(length=256), unique=True, nullable=False)
phone = db.Column(db.String(length=11), nullable=False)
def __repr__(self) -> str:
return "<Student id {}>".format(self.id)
class Course(db.Model):
"""
Sample Course Table
"""
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(length=100), nullable=False)
faculty = db.Column(db.String(length=100), nullable=False)
duration = db.Column(db.Integer)
def __repr__(self) -> str:
return "<Course id {}>".format(self.id)
student_courses = db.Table('studentcourses',
db.Column('student_id', db.Integer, db.ForeignKey('student.id'), primary_key=True),
db.Column('course_id', db.Integer, db.ForeignKey('course.id'), primary_key=True)
)
class Institute(db.Model):
"""
Sample Institute Table
"""
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(length=100), nullable=False)
email = db.Column(db.String(length=256), unique=True, nullable=False)
phone = db.Column(db.String(length=11), nullable=False)
def __repr__(self) -> str:
return "<Institute id {}>".format(self.id)