-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxmodels.py
47 lines (31 loc) · 1.39 KB
/
xmodels.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
# coding: utf-8
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class Course(db.Model):
__tablename__ = 'course'
stu_id = db.Column(db.ForeignKey('student.stu_id'), nullable=False)
course_name = db.Column(db.String, primary_key=True)
c_hours = db.Column('c_hours', db.Integer, nullable=False)
stu = db.relationship('Student', primaryjoin='Course.stu_id == Student.stu_id', backref='courses')
t_result = db.Table(
'result',
db.Column('stu_id', db.ForeignKey('student.stu_id'), nullable=False),
db.Column('stu_name', db.String, nullable=False),
db.Column('t_marks', db.Integer, nullable=False),
db.Column('o_marks', db.Integer, nullable=False),
db.Column('c_hours', db.Integer, nullable=False),
db.Column('gpa', db.Float(53)),
db.Column('course_name', db.ForeignKey('course.course_name'), nullable=False)
)
class Student(db.Model):
__tablename__ = 'student'
stu_id = db.Column(db.Integer, primary_key=True)
stu_name = db.Column(db.String(20), nullable=False)
email = db.Column(db.String, nullable=False)
password = db.Column('pass', db.String, nullable=False)
class Teacher(db.Model):
__tablename__ = 'teacher'
t_id = db.Column(db.Integer, primary_key=True)
t_name = db.Column(db.String(20), nullable=False)
email = db.Column(db.String, nullable=False)
_pass = db.Column('pass', db.String, nullable=False)