-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
33 lines (25 loc) · 871 Bytes
/
models.py
File metadata and controls
33 lines (25 loc) · 871 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
30
31
32
33
from sqlalchemy import Column, Integer, String, Date, BigInteger
from sqlalchemy.orm import validates, declarative_base
import sys
import os
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.dirname(current_dir)
sys.path.append(parent_dir)
from database import Base
class Entertainment(Base):
__tablename__ = "entertainment"
ID = Column(Integer, primary_key=True, index=True)
workName = Column(String(50))
Category = Column(String(20))
Score = Column(Integer)
Writer = Column(String(20))
NTCE_DE = Column(Date)
class User(Base):
__tablename__ = "user"
ID = Column(BigInteger, primary_key=True, index=True)
userAccess = Column(Integer, default=10)
@validates("userAccess")
def validate_access(self, access):
if access < 0:
raise ValueError("Access is finished.")
return access