Exemple #1
0
class Task(db.Model):
    __tablename__ = 'task'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    #名字
    name = db.Column(db.String(50), nullable=False)
    #创建时间
    time = db.Column(db.DateTime, nullable=False)
    #定时时间
    run_time = db.Column(db.DateTime, nullable=True)
    #爬虫任务
    spider_type = db.Column(db.String(10), nullable=False)
    #状态,0为未执行
    status = db.Column(db.Integer, nullable=True, default=0)
    #爬虫类型,0是即时爬虫,1是定时爬虫,暂定
    type = db.Column(db.Integer, nullable=True, default=0)

    def to_json(self):
        return {
            'id': self.id,
            'name': self.name,
            'time': str(self.time),
            'run_time': self.run_time,
            'spider_task': self.spider_type,
            'status': self.status,
            'type': self.type
        }
Exemple #2
0
class Hotel(db.Model):
    __tablename__ = 'hotel'
    id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    hotel_name = db.Column(db.String(25))
    city = db.Column(db.String(255),
                     db.ForeignKey('city.cityname'),
                     nullable=True)
    pic = db.Column(db.Text, nullable=True)
    price = db.Column(db.Integer, nullable=True)
    types = db.Column(db.String(4), nullable=True)
    url = db.Column(db.Text, nullable=True)
    address = db.Column(db.String(100), nullable=True)
    source = db.Column(db.String(20), nullable=True)

    def to_json(self):
        return {
            'hotel_name': self.hotel_name,
            'city': self.city,
            'pic': self.pic,
            'price': self.price,
            'types': self.types,
            'url': self.url,
            'address': self.address,
            'source': self.source
        }
Exemple #3
0
class Food(db.Model):
    __tablename__ = 'food'
    id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    food_name = db.Column(db.String(50))
    food_link = db.Column(db.Text, nullable=True)
    food_pic = db.Column(db.Text, nullable=True)
    city = db.Column(db.String(50), db.ForeignKey('city.cityname'))

    def to_json(self):
        return {
            'food_name': self.food_name,
            'food_link': self.food_link,
            'food_pic': self.food_pic,
            'city': self.city
        }
class City(db.Model):
    __tablename__ = 'city'
    cityname = db.Column(db.String(50), primary_key=True)
    introduction = db.Column(db.Text, nullable=True)
    scenic_time_crawl = db.Column(db.Date, nullable=True)
    lat = db.Column(db.String(50), nullable=True)
    lng = db.Column(db.String(50), nullable=True)
    hotel_time_crawl = db.Column(db.Date, nullable=True)
    food_time_crawl = db.Column(db.Date, nullable=True)

    def to_json(self):

        return {
            'cityname': self.cityname,
            'introduction': self.introduction,
            'scenic_time_crawl': self.scenic_time_crawl,
            'lat': self.lat,
            'lng': self.lng,
            'hotel_time_crawl': self.hotel_time_crawl,
            'food_time_crawl': self.food_time_crawl
        }
class Senic_spot(db.Model):
    _tablename__ = 'senic_spot_name'
    id = db.Column(db.Integer, nullable=False, primary_key=True)
    senic_spot_name = db.Column(db.String(50), nullable=True)
    introduction = db.Column(db.String(255),
                             db.ForeignKey('city.cityname'),
                             nullable=True)
    pic = db.Column(db.Text, nullable=True)
    price = db.Column(db.Integer, nullable=True)
    types = db.Column(db.String(4), nullable=True)
    url = db.Column(db.Text, nullable=True)
    levels = db.Column(db.String(20), nullable=True)
    source = db.Column(db.String(20), nullable=True)
    city = db.Column(db.String(25),
                     db.ForeignKey('city.cityname'),
                     nullable=True)

    def to_json(self):
        return {
            'senic_spot_name': self.senic_spot_name,
            'introduction': self.introduction,
            'pic': self.pic,
            'price': self.price,
            'types': self.types,
            'url': self.url,
            'levels': self.levels,
            'source': self.source,
            'city': self.city
        }
Exemple #6
0
class User(db.Model):
    __tablename__ = 'user'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    account = db.Column(db.String(13), nullable=False)
    password = db.Column(db.String(50), nullable=False)