class User(db.Model): # id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(150), unique=True, nullable=False) # 중복 저장 방지 password = db.Column(db.String(200), nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) # 중복 저장 방지
class User(db.Model): id = db.Column(db.Integer, primary_key=True) # 자동으로 증가하는 user 모델의 기본 키 # nullable = False : null값 허용하지 않음 # unique = True : 같은 값을 저장할 수 없다. 이렇게 해야 중복되어 저장되지 않음 username = db.Column(db.String(150), unique=True, nullable=False) password = db.Column(db.String(200), nullable=False) email = db.Column(db.String(120), unique=True, nullable=False)
class VocaWord(db.Model): # 단어 id = db.Column(db.Integer, primary_key=True) voca_id = db.Column(db.Integer, db.ForeignKey('voca.id', ondelete="CASCADE")) voca = db.relationship('Voca', backref=db.backref('voca_set', cascade='all, delete-orphan')) word = db.Column(db.String(200), nullable=False) # 단어장 단어 mean = db.Column(db.String(200), nullable=False) # 단어장 뜻
class User(db.Model): user_id = db.Column(db.Integer, primary_key=True) pw = db.Column(db.String(20), nullable=False) name = db.Column(db.String(10), nullable=False) age = db.Column(db.Integer, nullable=False) address = db.Column(db.String(40), nullable=False) birth = db.Column(db.String(20), nullable=False) gender = db.Column(db.String(2), nullable=False) create_date = db.Column(db.DateTime(), nullable=False)
class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(150), unique=True, nullable=False) password = db.Column(db.String(200), nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) intro = db.Column(db.Text(), nullable=True) image_path = db.Column(db.String(300), nullable=True) create_date = db.Column(db.DateTime(), nullable=False) modify_date = db.Column(db.DateTime(), nullable=True)
class Review(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(100), nullable=False) # actors, rolse 다 () 이렇게 세트로 묶어서 입력할 것 actors = db.Column(db.Text(), nullable=False) roles = db.Column(db.Text(), nullable=False) # (극장, 좌석)이 세트로 묶어서 입력할 것 seat = db.Column(db.String(50), nullable=False) content = db.Column(db.Text(), nullable=False) create_date = db.Column(db.String(16), nullable=False)
class Voca(db.Model): # 단어장 id = db.Column(db.Integer, primary_key=True) # 단어장 고유번호 vocaname = db.Column(db.String(150), nullable=False) # 단어장 이름 user_id = db.Column(db.String(150), db.ForeignKey('user.id', ondelete="CASCADE")) user = db.relationship( 'User', backref=db.backref('voca_set', cascade='all, delete-orphan')) # 유저 데이터 RK & 역참조 tag = db.Column(db.Text(), nullable=False) # 단어장 태그
class Apireq(db.Model): #기본키 id = db.Column(db.Integer, primary_key=True) subject = db.Column(db.String(200), nullable=False) service_key = db.Column(db.String(100), nullable=False) target_url = db.Column(db.String(200), nullable=False) parameter = db.Column(db.String(200), nullable=False) result_format = db.Column(db.String(200), nullable=True) create_date = db.Column(db.DateTime(), nullable=False) modify_date = db.Column(db.DateTime(), nullable=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='CASCADE'), nullable=False) user = db.relationship('User', backref=db.backref('apireq_set'))
class Apires(db.Model): #기본키 id = db.Column(db.Integer, primary_key=True) apireq_id = db.Column(db.Integer, db.ForeignKey('apireq.id', ondelete='CASCADE')) apireq = db.relationship('Apireq', backref=db.backref('apires_set')) parameter = db.Column(db.String(200), nullable=False) result_format = db.Column(db.String(200), nullable=True) result_data = db.Column(db.Text(), nullable=False) create_date = db.Column(db.DateTime(), nullable=False) modify_date = db.Column(db.DateTime(), nullable=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='CASCADE'), nullable=False) user = db.relationship('User', backref=db.backref('apires_set'))
class Question(db.Model): id = db.Column(db.Integer, primary_key=True) subject = db.Column(db.String(200), nullable=False) content = db.Column(db.Text(), nullable=False) create_date = db.Column(db.DateTime(), nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='CASCADE'), nullable=False) user = db.relationship('User', backref=db.backref('question_set'))
class Question(db.Model): #질문을 등록할 수 있는 테이블 생성 id = db.Column(db.Integer, primary_key=True) #이 테이블에 id라는 컬럼을 만들고, int형 데이터 넣어라. subject = db.Column(db.String(200), nullable=False) #200글자로 제한. nullable= 비어두기 허용 유무.. content = db.Column(db.Text(), nullable=False) create_date = db.Column(db.DateTime(), nullable=False)
class Question(db.Model ): #SQLAlchemy의 Model을 인자로 받음. DB에서 Question이라는 테이블을 생성하는 것과 동일 id = db.Column(db.Integer, primary_key=True) #이 변수들을 각각 Question 테이블의 컬럼이 됨 subject = db.Column(db.String(200), nullable=False) #여기서 200은 사이즈 제한 content = db.Column(db.Text(), nullable=False) # String과 달리 Text는 글자 수 제한이 없음 create_date = db.Column(db.DateTime(), nullable=False)
class Userinfo(db.Model): id = db.Column(db.Integer, primary_key=True) pw = db.Column(db.Integer, nullable=False) name = db.Column(db.String(200), nullable=False) age = db.Column(db.Integer, nullable=False) address = db.Column(db.Text(), nullable=False) birthday = db.Column(db.DateTime(), nullable=False) gender = db.Column(db.Integer, nullable=False) # 남=1, 여=2 create_date = db.Column(db.DateTime(), nullable=False)
class Question(db.Model): id = db.Column(db.Integer, primary_key=True) subject = db.Column(db.String(200), nullable=False) content = db.Column(db.Text(), nullable=False) create_date = db.Column(db.DateTime(), nullable=False) modify_date = db.Column(db.DateTime(), nullable=True) user_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="CASCADE"), nullable=False) user = db.relationship("User", backref=db.backref("question_set"))
class user_info(db.Model): id = db.Column(db.Integer, primary_key=True) pw = db.Column(db.String(10), nullable=False) name = db.Column(db.String(5), nullable=False) phone = db.Column(db.String(15), nullable=False) age = db.Column(db.String(2), nullable=False) birth = db.Column(db.String(8), nullable=False) gender = db.Column(db.String(2), nullable=False) subject = db.Column(db.String(200), nullable=False) content = db.Column(db.Text(), nullable=False) create_date = db.Column(db.DateTime(), nullable=False)
class Question(db.Model): id = db.Column(db.Integer, primary_key=True) subject = db.Column(db.String(200), nullable=False) content = db.Column(db.Text(), nullable=False) # 글자수 제한없음 Text create_date = db.Column(db.DateTime(), nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='CASCADE'), nullable=False) # server_default='1') user = db.relationship('User', backref=db.backref('question_set')) modify_date = db.Column(db.DateTime(), nullable=True) voter = db.relationship('User', secondary=question_voter, backref=db.backref('question_voter_set'))
class Question(db.Model): id = db.Column(db.Integer, primary_key = True) subject = db.Column(db.String(200), nullable=False) content = db.Column(db.Text(), nullable=False) create_date = db.Column(db.DateTime(), nullable=False) # (p.162) User 모델 데이터의 id 값을 Question 모델에 포함시킴. #db.ForeignKey : 다른 모델과 연결. ondelete='CASCADE': User 모델 데이터가 삭제되면 Question 모델 데이터도 삭제됨. user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='CASCADE'), nullable=False) user = db.relationship('User', backref = db.backref('question_set')) # p.182 nullable=True!! modify_date = db.Column(db.DateTime(), nullable=True) # p.210 Question 모델에 voter 필드 추가하기 voter = db.relationship('User', secondary=question_voter, backref = db.backref('question_voter_set'))
class Question(db.Model): #nullable 비어있는값 들어올수없음 의미 디폴드값은 true id = db.Column(db.Integer, primary_key=True) #primary_key 중복 안됌,integer id숫자값 subject = db.Column(db.String(200), nullable=False) #string제목처럼 제한된 글자수 content = db.Column(db.Text(), nullable=False) #text글자수 제한 없음 create_date = db.Column(db.DateTime(), nullable=False) #날짜와 시간 user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='CASCADE'), nullable=True) user = db.relationship('User', backref=db.backref('question_set')) modify_date = db.Column(db.DateTime(), nullable=True) voter = db.relationship('User', secondary=question_voter, backref=db.backref('question_voter_set'))
class User_info(db.Model): id = db.Column(db.String(10), primary_key=True) pw = db.Column(db.String(100), nullable=False) name = db.Column(db.String(10), nullable=False) age = db.Column(db.Integer, nullable=False) addr = db.Column(db.String(3), nullable=False) birth = db.Column(db.String(6), nullable=False) sex = db.Column(db.Text(), nullable=False) create_date = db.Column(db.String(6), nullable=False)
class Question(db.Model): # 플라스크는 데이터 타입이 db.Interger 이고 기본키로 지정한 속성은 # 값이 자동으로 증가하는 특징이 있어서 데이터를 저장할 떄 해당 속성값을 지정하지 않아도 # 1씩 자동으로 증가하여 저장된다. id = db.Column(db.Integer, primary_key=True) subject = db.Column(db.String(200), nullable=False) content = db.Column(db.Text(), nullable=False) create_date = db.Column(db.DateTime(), nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='CASCADE'), nullable=False) user = db.relationship('User', backref=db.backref( 'question_set')) # Question 모델에서 User 모델을 참조하기 위한 필드 modify_date = db.Column(db.DateTime(), nullable=True) voter = db.relationship('User', secondary=question_voter, backref=db.backref('question_vote_set'))
class Question(db.Model): id = db.Column(db.Integer, primary_key=True) subject = db.Column(db.String(200), nullable=False) content = db.Column(db.Text(), nullable=False) create_date = db.Column(db.DateTime(), nullable=False) modify_date = db.Column(db.DateTime(), nullable=True) user_id = db.Column( db.Integer, db.ForeignKey("user.id", ondelete="CASCADE"), nullable=False, # server_default="1", ) # User 스키마의 id를 참조함 user = db.relationship( "User", backref=db.backref("question_set")) # question을 이용해 user를 참조하기 위함 voter = db.relationship("User", secondary=question_voter, backref=db.backref("question_voter_set"))
class Question(db.Model): #기본키 id = db.Column(db.Integer, primary_key=True) subject = db.Column(db.String(200), nullable=False) content = db.Column(db.Text(), nullable=False) create_date = db.Column(db.DateTime(), nullable=False) modify_date = db.Column(db.DateTime(), nullable=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='CASCADE'), nullable=False) user = db.relationship('User', backref=db.backref( 'question_set')) #backref : User 모델 데이터를 통해 Question 모델 데이터를 참조 voter = db.relationship('User', secondary=question_voter, backref=db.backref('question_voter_set')) menu_id = db.Column(db.Integer(), db.ForeignKey('menu.id', ondelete='CASCADE'), nullable=False, server_default='1') view_cnt = db.Column(db.Integer, nullable=False, server_default='0')
class Question(db.Model): id = db.Column(db.Integer, primary_key=True) subject = db.Column(db.String(200), nullable=False) content = db.Column(db.Text(), nullable=False) create_date = db.Column(db.DateTime(), nullable=False) # db.ForeignKey('user.id', ondelete='CASCADE') # User 모델의 id 값과 연결 # ondelete='CASCADE' user 데이터 삭제 시에 Question 모델 데이터도 함께 삭제되도록함 user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='CASCADE'), nullable=False) user = db.relationship('User', backref=db.backref('question_set')) # 수정일자 컬럼 modify_date = db.Column(db.DateTime(), nullable=True) # 추천인 # secondary: voter가 다대다 관계이며, question_voter 테이블을 참조한다. voter = db.relationship('User', secondary=question_voter, backref=db.backref('question_voter_set'))
class Question(db.Model): # 모든 모델의 기본 클래스인 db.Model 상속받음. # 질문 모델 생성. 속성 = db.Column(데이터 타입, ~) # primary_key = 기본 키. nullable = 속성에 빈 값을 허용할 것인지. id = db.Column(db.Integer, primary_key=True) subject = db.Column(db.String(200), nullable=False) content = db.Column(db.Text(), nullable=False) create_date = db.Column(db.DateTime(), nullable=False) modify_date = db.Column(db.DateTime(), nullable=True) # secondary 설정으로 voter는 N:N 관계이며 question_voter 테이블 참조함을 알려줌 # 어떤 계정이 a_user라는 객체로 참조되면 backref에 의해 a_user.question_voter_set으로 질문 구할 수 있게 됨 # backref 설정에 사용하는 이름은 중복 불가 voter = db.relationship('User', secondary=question_voter, backref=db.backref('question_voter_set')) # question model에 user_id, user field 추가 # user_id : User model data의 id값을 Question model에 포함시키기 위함 user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='CASCADE'), nullable=False) # user : Question model에서 User model을 참조하기 위한 field # backref로 User model data 통해 Question model data 참조 user = db.relationship('User', backref=db.backref('question_set'))
class Question(db.Model): id = db.Column(db.Integer, primary_key=True) subject = db.Column(db.String(200), nullable=False) content = db.Column(db.Text(), nullable=False) create_date = db.Column(db.DateTime(), nullable=False)
class User(db.Model): id = db.Column(db.Integer, primary_key=True) # id 값은 자동으로 증가하는 User 모델의 기본키 username = db.Column(db.String(150), unique=True, nullable=False) password = db.Column(db.String(200), nullable=False) email = db.Column(db.String(120), unique=True, nullable=False)
class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(150), nullable=False) #unique는 같은 값을 저장할 수 없다는 뜻이다. password = db.Column(db.String(200), nullable=False) email = db.Column(db.String(120), unique=True, nullable=False)
class BTS_vote(db.Model): name = db.Column(db.String(100), primary_key=True) count = db.Column(db.Integer, nullable=False)
class profile(db.Model): id = db.Column(db.Integer, primary_key=True) profile_msg = db.Column(db.String(200), nullable=True)
class View(db.Model): id = db.Column(db.Integer, primary_key=True) theater = db.Column(db.String(50), nullable=False) seat = db.Column(db.String(20), nullable=False) score = db.Column(db.Integer, nullable=False) comment = db.Column(db.Text(), nullable=False)