-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
34 lines (25 loc) · 1.12 KB
/
models.py
File metadata and controls
34 lines (25 loc) · 1.12 KB
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
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String
from sqlalchemy.orm import relationship
# database.py에서 생성한 Base import
from database import Base
# Base를 상속 받아 SQLAlchemy model 생성
class User(Base):
# 해당 모델이 사용할 table 이름 지정
__tablename__ = "users"
# Model의 attribute(column) 생성 -> "="를 사용하여 속성을 정의
nickName = Column(String, primary_key=True, index=True)
inputLevel = Column(String,index=True)
totalScore = Column(Integer)
readScore = Column(Integer, default=0)
writeScore = Column(Integer, default=0)
vocaScore = Column(Integer, default=0)
testCompleted = Column(Boolean, default=False)
# 다른 테이블과의 관계 생성
# items = relationship("Item", back_populates="owner")
# class Item(Base):
# __tablename__ = "items"
# id = Column(Integer, primary_key=True, index=True)
# title = Column(String, index=True)
# description = Column(String, index=True)
# owner_id = Column(Integer, ForeignKey("users.id"))
# owner = relationship("User", back_populates="items")