Ejemplo n.º 1
0
class Spaceship(db.Model):
    __tablename__ = "spaceship"

    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String, nullable=False)

    def __repr__(self):
        return f"<Spaceship (id={self.id}, title={self.title})"
Ejemplo n.º 2
0
class Human(db.Model):
    __tablename__ = "human"

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String, nullable=False)
    status = db.Column(db.Integer, nullable=False)

    def __repr__(self):
        return f"<Human (id={self.id}, name={self.name}, status={self.status})"
Ejemplo n.º 3
0
class Murder(db.Model):
    __tablename__ = "murder"

    id = db.Column(db.Integer, primary_key=True)
    humanid = db.Column(db.Integer, db.ForeignKey("human.id"), nullable=False)
    alienid = db.Column(db.Integer, db.ForeignKey("alien.id"), nullable=False)
    date = db.Column(db.Date, nullable=False, default=date.today)

    human = db.relation("Human", backref="murder")
    alien = db.relation("Alien", backref="murder")
Ejemplo n.º 4
0
class Redemption(db.Model):
    __tablename__ = "redemption"

    id = db.Column(db.Integer, primary_key=True)
    humanid = db.Column(db.Integer, db.ForeignKey("human.id"), nullable=False)
    shipid = db.Column(db.Integer,
                       db.ForeignKey("spaceship.id"),
                       nullable=False)
    date = db.Column(db.Date, nullable=False, default=date.today)

    human = db.relation("Human", backref="redemption")
    ship = db.relation("Spaceship", backref="redemption")
Ejemplo n.º 5
0
class Experiment(db.Model):
    __tablename__ = "experiment"

    id = db.Column(db.Integer, primary_key=True)
    humanid = db.Column(db.Integer, db.ForeignKey("human.id"), nullable=False)
    shipid = db.Column(db.Integer,
                       db.ForeignKey("spaceship.id"),
                       nullable=False)
    date = db.Column(db.Date, nullable=False, default=date.today)
    #relationships
    aliens = db.relation("Alien",
                         secondary=Experiment_alien,
                         backref="experiments")
Ejemplo n.º 6
0
class Excursion(db.Model):
    __tablename__ = "excursion"

    id = db.Column(db.Integer, primary_key=True)
    alienid = db.Column(db.Integer, db.ForeignKey("alien.id"), nullable=False)
    shipid = db.Column(db.Integer,
                       db.ForeignKey("spaceship.id"),
                       nullable=False)
    date = db.Column(db.Date, nullable=False, default=date.today)
    #relationships
    humans = db.relation("Human",
                         secondary=Excursion_human,
                         backref="excursions")
Ejemplo n.º 7
0
class Alien(db.Model):
    __tablename__ = "alien"

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String, nullable=False)
    status = db.Column(db.Integer, nullable=False)

    # def __init__(self, name, status):

    #     self.name = name
    #     self.status = status

    def __repr__(self):
        return f"<Alien (id={self.id}, name={self.name}, status={self.status})"
Ejemplo n.º 8
0
class Transportation(db.Model):
    __tablename__ = "transportation"

    id = db.Column(db.Integer, primary_key=True)
    humanid = db.Column(db.Integer, db.ForeignKey("human.id"), nullable=False)
    alienid = db.Column(db.Integer, db.ForeignKey("alien.id"), nullable=False)
    fromshipid = db.Column(db.Integer,
                           db.ForeignKey("spaceship.id"),
                           nullable=False)
    toshipid = db.Column(db.Integer,
                         db.ForeignKey("spaceship.id"),
                         nullable=False)
    date = db.Column(db.Date, nullable=False, default=date.today)

    human = db.relation("Human", backref="transportation")
    alien = db.relation("Alien", backref="transportation")
    fromShip = db.relation("Spaceship",
                           foreign_keys=[fromshipid])  #TODO: verify backrefs
    toShip = db.relation("Spaceship", foreign_keys=[toshipid])
Ejemplo n.º 9
0
    id = db.Column(db.Integer, primary_key=True)
    humanid = db.Column(db.Integer, db.ForeignKey("human.id"), nullable=False)
    alienid = db.Column(db.Integer, db.ForeignKey("alien.id"), nullable=False)
    shipid = db.Column(db.Integer,
                       db.ForeignKey("spaceship.id"),
                       nullable=False)
    date = db.Column(db.Date, nullable=False, default=date.today)
    #relationships
    human = db.relation("Human", backref="abduction")
    alien = db.relation("Alien", backref="abduction")
    ship = db.relation("Spaceship", backref="abduction")


Excursion_human = db.Table(
    'excursion_human', db.Model.metadata,
    db.Column('excursionid', db.Integer, db.ForeignKey("excursion.id")),
    db.Column('humanid', db.Integer, db.ForeignKey("human.id")),
    db.PrimaryKeyConstraint('excursionid', 'humanid'))


class Excursion(db.Model):
    __tablename__ = "excursion"

    id = db.Column(db.Integer, primary_key=True)
    alienid = db.Column(db.Integer, db.ForeignKey("alien.id"), nullable=False)
    shipid = db.Column(db.Integer,
                       db.ForeignKey("spaceship.id"),
                       nullable=False)
    date = db.Column(db.Date, nullable=False, default=date.today)
    #relationships
    humans = db.relation("Human",