コード例 #1
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True, nullable=False)
    email = db.Column(db.String(60), unique=True, nullable=False)
    password = db.Column(db.String(120), nullable=False)

    def __repr__(self):
        return f"User('{self.username}', '{self.email}')"
コード例 #2
0
class ArticleDB(db.Model):
    __tablename__ = "article"

    id = db.Column(db.Integer, primary_key=True)
    _name = db.Column(db.String(20), nullable=False)
    link = db.Column(db.String(40), nullable=False)
    header = db.Column(db.String(100), nullable=False)
    text = db.Column(db.String(3000), nullable=False)
コード例 #3
0
class Participant(Base): 
	first_name = db.Column(db.String(250))
	last_name = db.Column(db.String(250))
	sex = db.Column(db.String(1))
	birth_date = db.Column(db.Date)

	def __init__(self, first_name, last_name, sex, birth_date): 
		self.first_name = first_name
		self.last_name = last_name
		self.sex = sex
		self.birth_date = birth_date
コード例 #4
0
class RTEvent(Base):
    event_reference = db.Column(db.String(250), unique=True)
    venue = db.Column(db.String(250))
    event_id = db.Column(db.Integer, db.ForeignKey('event.id'))
    event = db.relationship('Event',
                            backref=db.backref('rt_to_event', lazy='dynamic'))

    def __init__(self, event_id, event_reference, venue):
        self.event_id = event_id
        self.event_reference = event_reference
        self.venue = venue
コード例 #5
0
ファイル: sas_models.py プロジェクト: coertzec/scraper
class SASCategory(Base):
    category_reference = db.Column(db.String(250), unique=True)
    stage_reference = db.Column(db.String(250), unique=True)
    category_id = db.Column(db.Integer, db.ForeignKey('category.id'))
    category = db.relationship('Category',
                               backref=db.backref('sas_to_category',
                                                  lazy='dynamic'))

    def __init__(self, category_reference, stage_reference, category_id):
        self.category_reference = category_reference
        self.stage_reference = stage_reference
        self.category_id = category_id
コード例 #6
0
class CycloneInfo(db.Model):
    cyclone_id = db.Column(db.String(20),
                           unique=True,
                           primary_key=True,
                           nullable=False)
    cyclone_name = db.Column(db.String(40), nullable=False)
    region = db.Column(db.String(30), nullable=False)
    cyclone_status = db.Column(db.Boolean, default=True, nullable=False)

    def __repr__(self):
        return '<CycloneInfo %r>' % self.cyclone_id

    def toJSON(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}
コード例 #7
0
class EventStage(Base):
	name	= db.Column(db.String(250))
	event_id = db.Column(db.Integer, db.ForeignKey('event.id'))
	event = db.relationship('Event', backref=db.backref('event_stage_event', lazy='dynamic'))
	results = relationship("Result")

	def __init__(self, name, event_id): 
		self.name = name
		self.event_id = event_id
コード例 #8
0
class CategoryStage(Base):
	name	= db.Column(db.String(250))
	category_id = db.Column(db.Integer, db.ForeignKey('category.id'))
	category = db.relationship('Category', backref=db.backref('category', lazy='dynamic'))
	results = relationship("Result")

	def __init__(self, name, category_id): 
		self.name = name 
		self.category_id = category_id
コード例 #9
0
class Event(Base): 
	title	= db.Column(db.String(250), unique=True)
	date 	= db.Column(db.Date)
	categories = relationship("Category")
	event_stages = relationship("EventStage")

	def __init__(self, title, date): 
		self.title = title
		self.date = date 
コード例 #10
0
class Category(Base):
	name	= db.Column(db.String(250), nullable=False)
	event_id = db.Column(db.Integer, db.ForeignKey('event.id'))
	event = db.relationship('Event', backref=db.backref('event', lazy='dynamic'))
	category_stages = relationship("CategoryStage")
	results = relationship("Result")
    
	def __init__(self,name, event_id): 
		self.name = name
		self.event_id = event_id
コード例 #11
0
class RTEventStage(Base):
    stage_reference = db.Column(db.String(250), unique=True)
    event_stage_id = db.Column(db.Integer, db.ForeignKey('event_stage.id'))
    event_stage = db.relationship('EventStage',
                                  backref=db.backref('rt_event_stage',
                                                     lazy='dynamic'))

    def __init__(self, event_stage_id, stage_reference):
        self.event_stage_id = event_stage_id
        self.stage_reference = stage_reference
コード例 #12
0
ファイル: models.py プロジェクト: arsyaduniten/banjirapi
class Info(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    state = db.Column(db.String(255))
    station_name = db.Column(db.String(255))
    district = db.Column(db.String(255))
    river_basin = db.Column(db.String(255))
    last_update = db.Column(db.DateTime)
    water_level = db.Column(db.Float(asdecimal=True))

    def __init__(self, station_name, district, river_basin, last_update,
                 water_level, state):
        self.state = state
        self.station_name = station_name
        self.district = district
        self.river_basin = river_basin
        self.last_update = last_update
        self.water_level = water_level

    def __repr__(self):
        return '<Station %d>' % self.id
コード例 #13
0
ファイル: sas_models.py プロジェクト: coertzec/scraper
class SASCategoryStage(Base):
    stage_reference = db.Column(db.String(250), unique=True)
    category_stage_id = db.Column(db.Integer,
                                  db.ForeignKey('category_stage.id'))
    category_stage = db.relationship('CategoryStage',
                                     backref=db.backref('category_stage',
                                                        lazy='dynamic'))

    def __init__(self, category_stage_id, stage_reference):
        self.category_stage_id = category_stage_id
        self.stage_reference = stage_reference
コード例 #14
0
class TrackData(db.Model):
    cyclone_id = db.Column(db.String(20),
                           db.ForeignKey(CycloneInfo.cyclone_id),
                           primary_key=True,
                           nullable=False)
    synoptic_time = db.Column(db.BigInteger, nullable=False, primary_key=True)
    latitude = db.Column(db.Float, default=0, nullable=False)
    longitude = db.Column(db.Float, default=0, nullable=False)
    intensity = db.Column(db.Integer, default=0, nullable=False)

    def __repr__(self):
        return '<TrackData %r>' % self.cyclone_id

    def toJSON(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}
コード例 #15
0
class ForecastData(db.Model):
    cyclone_id = db.Column(db.String(20),
                           db.ForeignKey(CycloneInfo.cyclone_id),
                           nullable=False,
                           primary_key=True)
    forecast_time = db.Column(db.BigInteger, nullable=False, primary_key=True)
    predicted_time = db.Column(db.BigInteger, nullable=False, primary_key=True)
    latitude = db.Column(db.Float, default=0, nullable=False)
    longitude = db.Column(db.Float, default=0, nullable=False)
    intensity = db.Column(db.Integer, default=0, nullable=False)

    def __repr__(self):
        return '<ForecastData %r>' % self.cyclone_id

    def toJSON(self):
        return {
            attr.name: getattr(self, attr.name)
            for attr in self.__table__.columns
        }