-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.py
More file actions
29 lines (21 loc) · 841 Bytes
/
database.py
File metadata and controls
29 lines (21 loc) · 841 Bytes
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
from sqlalchemy import create_engine, Column, String, Integer, ForeignKey
from sqlalchemy.orm import declarative_base
from sqlalchemy.orm import relationship
engine = create_engine("sqlite:///lesson_and_tutor.db")
Base = declarative_base()
class Lesson(Base):
__tablename__ = "lessons"
lesson_id = Column(Integer, primary_key=True)
course_name = Column(String, nullable=False)
course_id = Column(String, nullable=False, unique=True)
course_url = Column(String, nullable=False)
price = Column(String)
level = Column(String)
tutors = relationship("Tutor")
class Tutor(Base):
__tablename__ = "tutors"
tutor_id = Column(Integer, primary_key=True)
full_name = Column(String)
company = Column(String)
lesson_id = Column(Integer, ForeignKey("lessons.lesson_id"))
metadata = Base.metadata