コード例 #1
0
def db(app, request):
    def teardown():
        _db.drop_all()
        # os.unlink(TestConfig.SQLALCHEMY_DATABASE_URI)

    _db.app = app
    _db.create_all()

    request.addfinalizer(teardown)
    return _db
コード例 #2
0
ファイル: model.py プロジェクト: hades72/DOAN
    Plane_Id = Column(Integer, ForeignKey(Plane.Id), nullable=False)
    FlightRoute_Id = Column(Integer, ForeignKey(FlightRoute.Id), nullable=False)

    FlightRoute = relationship('FlightRoute', foreign_keys=[FlightRoute_Id])
    Plane = relationship('Plane', foreign_keys=[Plane_Id])
    def __str__(self):
        return self.Name
class Plane_TicketType(db.Model):
    __tablename__ = 'PLANE_TICKETTYPE'
    Plane_Id = Column(Integer, ForeignKey(Plane.Id), nullable=False, primary_key=True)
    TicketType_Id = Column(Integer, ForeignKey(TicketType.Id), nullable=False,primary_key=True)
    Quantity = Column(Integer, nullable=False)
    Plane = relationship('Plane', foreign_keys=[Plane_Id])
    TicketType = relationship('TicketType', foreign_keys=[TicketType_Id])
    def __str__(self):
        return "no return"
class Ticket(db.Model):
    __tablename__ = 'TICKET'
    Id = Column(Integer, primary_key=True, autoincrement=True)
    User_Id = Column(Integer, ForeignKey(User.Id), nullable=False)
    User = relationship('User', foreign_keys=[User_Id])
    Plane_Id = Column(Integer, ForeignKey(Plane.Id), nullable=False)
    TicketType_Id = Column(Integer, ForeignKey(TicketType.Id), nullable=False)
    TicketType = relationship('TicketType', foreign_keys=[TicketType_Id])
    Plane = relationship('Plane', foreign_keys=[Plane_Id])
    def __str__(self):
        return self.Plane

if __name__ == '__main__':
    db.create_all()
コード例 #3
0
 def setUp(self):
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
     db.create_all()