class Competition(Base, DeclarativeBase): """The model for Book data""" __tablename__ = "competition" categories = orm.relationship(CategoryRelation, back_populates="competition") kernels = orm.relationship(Kernel, back_populates='competition')
class TechnologyRelation(DeclarativeBase): __tablename__ = "technology_relation" id = sa.Column(sa.Integer, primary_key=True) kernel_id = sa.Column(sa.Integer, ForeignKey("kernel.id")) technology_id = sa.Column(sa.Integer, ForeignKey("technology.id")) technology = orm.relationship("Technology", back_populates="kernels") kernel = orm.relationship("Kernel", back_populates="technologies")
class DataLinkRelation(DeclarativeBase): """The model for Book data""" __tablename__ = "data_link_relation" id = sa.Column(sa.Integer, primary_key=True) kernel_id = sa.Column(sa.Integer, ForeignKey("kernel.id")) data_link_id = sa.Column(sa.Integer, ForeignKey("data_link.id")) data_link = orm.relationship("DataLink", back_populates="kernels") kernel = orm.relationship("Kernel", back_populates="data_links")
class DataLink(Base, DeclarativeBase): """The model for Book data""" __tablename__ = "data_link" link = sa.Column(sa.Unicode(100)) source_type = sa.Column(VARCHAR(100, charset='utf8'), unique=True) kernels = orm.relationship(DataLinkRelation, back_populates="data_link")
class Kernel(Base, DeclarativeBase): """The model for Book data""" __tablename__ = "kernel" lang = sa.Column(sa.Enum(Lang)) notebook = sa.Column(sa.Boolean) votes = sa.Column(sa.Integer) best_score = sa.Column(sa.FLOAT) source_version = sa.Column(sa.Integer) competition_id = sa.Column(sa.Integer, ForeignKey("competition.id")) author_id = sa.Column(sa.Integer, ForeignKey("users.id")) competition = orm.relationship("Competition", back_populates="kernels") author = orm.relationship("User", back_populates="kernels") categories = orm.relationship(CategoryRelation, back_populates="kernel") technologies = orm.relationship(TechnologyRelation, back_populates="kernel") data_links = orm.relationship(DataLinkRelation, back_populates="kernel")
class Technology(Base, DeclarativeBase): """The model for Book data""" __tablename__ = "technology" kernels = orm.relationship(TechnologyRelation, back_populates="technology")
class Category(Base, DeclarativeBase): """The model for Category data""" __tablename__ = "category" description = sa.Column(VARCHAR(100, charset='utf8')) kernels = orm.relationship(CategoryRelation, back_populates="category")