-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.py
47 lines (35 loc) · 1.26 KB
/
db.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
from flask_sqlalchemy import SQLAlchemy
from context import app
db = SQLAlchemy(app)
class StudentDetail(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
name = db.Column(db.String(255))
rollno = db.Column(db.String(20))
class Attendance(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
student_id = db.Column(db.Integer, db.ForeignKey("student_detail.id"))
date = db.Column(db.Date)
status = db.Column(db.Boolean)
class Leave(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
student_id = db.Column(db.Integer, db.ForeignKey("student_detail.id"))
start = db.Column(db.Date)
end = db.Column(db.Date)
location = db.Column(db.String(255))
emergency_no = db.Column(db.String(20))
home_town = db.Column(db.Boolean)
status = db.Column(db.Boolean)
"""
from app import db, Student
student_john = Student(firstname='john', lastname='doe',
email='[email protected]', age=23,
bio='Biology student')
student_john.firstname
student_john.bio
db.session.add(student_john)
db.session.commit()
student_john.email = '[email protected]'
db.session.add(student_john)
db.session.commit()
Student.query.all()
"""