-
Notifications
You must be signed in to change notification settings - Fork 0
/
models_2.py
61 lines (47 loc) · 2.56 KB
/
models_2.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from sqlalchemy import Column, Date, Float, ForeignKey, Integer, String
from sqlalchemy.orm import relationship
from psql import Base, db, session
class ImdbSourcedEpisode(Base):
__tablename__ = 'imdb_sourced_episode'
season_id = Column(String(8), primary_key=True)
season = Column(Integer, nullable=False)
episode_num = Column(Integer, nullable=False)
title = Column(String(200), nullable=False)
original_air_date = Column(Date, nullable=False)
imdb_rating = Column(Float(3), nullable=False)
total_votes = Column(Integer, nullable=False)
description = Column(String(1000), nullable=True)
directorss = relationship("Directors", back_populates="imdbsourcedepisode", uselist = False)
writerss = relationship("Writers", back_populates="imdbsourcedepisode")
teleplaycoordinatorss = relationship("TeleplayCoordinators", back_populates="imdbsourcedepisode")
class WikiSourcedEpisode(Base):
__tablename__ = 'wiki_sourced_episode'
season_id = Column(String(8), primary_key=True)
season = Column(Integer, nullable=False)
episode_num_in_season = Column(Integer, nullable=False)
episode_num_overall = Column(Integer, nullable=False)
title = Column(String(200), nullable=False)
original_air_date = Column(Date, nullable=False)
prod_code = Column(String(20), nullable=True)
us_viewers = Column(Integer, nullable=True)
class Directors(Base):
__tablename__ = 'directors'
id = Column(Integer, primary_key=True, autoincrement=True)
season_id = Column(String(8), ForeignKey('imdb_sourced_episode.season_id'), nullable=False)
directed_by = Column(String(200), nullable=False)
imdbsourcedepisodes = relationship("ImdbSourcedEpisode", back_populates="directorss")
class Writers(Base):
__tablename__ = 'writers'
id = Column(Integer, primary_key=True, autoincrement=True)
season_id = Column(String(8), ForeignKey('imdb_sourced_episode.season_id'), nullable=False)
written_by = Column(String(200), nullable=False)
imdbsourcedepisodes = relationship("ImdbSourcedEpisode", back_populates="writerss")
class TeleplayCoordinators(Base):
__tablename__ = 'teleplay_coordinators'
id = Column(Integer, primary_key=True, autoincrement=True)
season_id = Column(String(8), ForeignKey('imdb_sourced_episode.season_id'), nullable=False)
teleplay_by = Column(String(200), nullable=False)
imdbsourcedepisodes = relationship("ImdbSourcedEpisode", back_populates="teleplaycoordinatorss")
def create():
Base.metadata.create_all(db)
create()