Ejemplo n.º 1
0
class IOU(db.Model):
    __tablename__ = 'iou'

    id = db.Column(db.Integer, primary_key=True)
    lender_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    borrower_id = db.Column(db.Integer,
                            db.ForeignKey('user.id'),
                            nullable=False)
    amount = db.Column(db.Integer, nullable=False)

    # lender = db.relationship("User", back_populates='User', foreign_keys=[id])
    # borrower = db.relationship("User", back_populates='User', foreign_keys=[id])

    def __init__(self, lender_id, borrower_id, amount):
        self.lender_id = lender_id
        self.borrower_id = borrower_id
        self.amount = amount

    def __repr__(self):
        return '<id {}>'.format(self.id)

    def serialize(self):
        return {
            'id': self.id,
            'lender': self.lender_id,
            'borrower': self.borrower_id,
            'amount': self.amount
        }
Ejemplo n.º 2
0
class Role(db.Model):
    """This class is used for role table in database."""

    __tablename__ = 'roles'

    id = db.Column(db.Integer, primary_key=True)
    role = db.Column(db.Text, nullable=False)
Ejemplo n.º 3
0
class T1(db.Model):
    __tablename__ = 't1'

    id = db.Column(db.Integer, primary_key=True)
    n_star = db.Column(db.Integer)
    short = db.Column(db.String(255))
    sentiment = db.Column(db.Float)
Ejemplo n.º 4
0
class Ingredient_in_recipe(db.Model):
    __tablename__ = 'ingredient_in_recipe'
    iid = db.Column(db.Integer, db.ForeignKey('ingredient.iid'), primary_key=True)
    rid = db.Column(db.Integer, db.ForeignKey('recipe.rid'), primary_key=True)
    quantity = db.Column(db.Float, nullable=False)

    def __init__(self, iid, rid, quantity):
        self.iid = iid
        self.rid = rid
        self.quantity = quantity

    @staticmethod
    def get_quantity_in_recipe(iid, rid):
        temp = Ingredient_in_recipe.query.filter(Ingredient_in_recipe.iid == iid). \
            filter(Ingredient_in_recipe.rid == rid).first()
        if temp is None:
            print("The object does not exist!")
        else:
            return temp

    @staticmethod
    def get_ingredients_in_recipe(rid):
        temp = Ingredient_in_recipe.query.filter(Ingredient_in_recipe.rid == rid).all()
        if temp is None:
            print("The object does not exist!")
        else:
            return temp

    @staticmethod
    def add(rid, iname, quantity):
        iid = Ingredient.query.filter_by(iname=iname).first().iid
        new_relation = Ingredient_in_recipe(iid, rid, quantity)
        app.logger.info('add new ingredient and recipe relationship')
        db.session.add(new_relation)
        db.session.commit()
Ejemplo n.º 5
0
class BaseModel(db.Model):
    __tablename__ = None
    id = db.Column(db.BigInteger(), primary_key=True)
    created_datetime = db.Column(db.DateTime(), default=datetime.now())

    def __init__(self, *args, **kwargs):
        super(BaseModel, self).__init__(*args, **kwargs)
        assert self.__tablename__, 'Table name is not defined'

    @classmethod
    async def all(cls) -> list or None:
        return await cls.query.gino.all()

    @classmethod
    async def filter(cls, *args) -> list or None:
        return await cls.query.where(*args).gino.all()

    @classmethod
    async def filter_and_first(cls, *args) -> object or None:
        return await cls.query.where(*args).gino.first()

    @classmethod
    async def filter_and_last(cls, *args) -> object or None:
        return await cls.query.where(*args).gino.last()

    @classmethod
    async def get_or_create(cls, *args) -> object:
        check = await cls.query.where(*args).gino.first()
        if check:
            return check
        return await cls.create(*args)
Ejemplo n.º 6
0
class SpiderResult(db.Model):
    __tablename__ = 'spider_result'

    id = db.Column(db.Integer, primary_key=True)
    spider_id = db.Column(db.Integer)
    timestamp = db.Column(db.DateTime)
    result = db.Column(db.String)
Ejemplo n.º 7
0
class ChatTfidf(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    chat_id = db.Column(db.Integer)
    tfidf_model = db.Column(db.PickleType, nullable=True)

    def __repr__(self):
        return '<Chat id %r>' % (self.chat_id)
Ejemplo n.º 8
0
class Article(db.Model):
    __tablename__ = 'article'
    article_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    auther = db.Column(db.Integer, db.ForeignKey('user.user_id'))
    title = db.Column(db.String(64))
    article_img = db.Column(db.String(64))  #文章图片
    brief = db.Column(db.Text)
    content = db.Column(db.Text)
    publish_time = db.Column(db.DateTime)  #发布时间
    label_id = db.Column(db.Integer, db.ForeignKey('label.label_id'))  #文章标签

    read_quantity = db.Column(db.Integer, default=0)  # 文章阅读量
    like_number = db.Column(db.Integer, default=0)  # 文章点赞数

    def to_dict(self):
        dic = {
            'article_id': self.article_id,
            'auther': self.auther,
            'title': self.title,
        }
        return dic

    @staticmethod
    def isReadArticle():
        return True
Ejemplo n.º 9
0
class ContactUsModel(db.Model):
    id = db.Column('id', db.Integer, primary_key=True)
    name = db.Column('name', db.String)
    email = db.Column(db.String, unique=True, nullable=False)
    creation_date = db.Column('creation_date',
                              db.Date,
                              default=datetime.utcnow)
Ejemplo n.º 10
0
class GroundTruth(db.Model):
    _tablename__ = 'ground_truth'
    id = Column(db.Integer(), primary_key=True)
    user_id = Column(db.Integer(), ForeignKey('user.id'))
    course_id =  course_id = db.Column(db.String(255))
    course_name = db.Column(db.String(255))
    choice =  db.Column(db.String(255))
    gt = db.Column(db.Integer())
    def __init__(self, user_id, course_id, course_name, choice, gt):
        self.user_id = user_id
        self.course_id = course_id
        self.course_name = course_name
        self.choice = choice
        self.gt = gt
    def get_user_id(self):
        return self.user_id
    def get_course_id(self):
        return self.course_id
    def get_course_name(self):
        return self.course_name
    def get_choice(self):
        return self.choice
    def get_gt(self):
        return self.gt
    def set_user_id(self,user_id):
        self.user_id = user_id
    def set_course_id(self,course_id):
        self.course_id = course_id
    def set_course_name(self,course_name):
        self.course_name = course_name
    def set_choice(self,choice):
        self.choice = choice
    def set_gt(self,gt):
        self.gt = gt
Ejemplo n.º 11
0
class ClassyJob(db.Model):
    __tablename__ = 'classy_jobs'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(1000))
    s3bucket = db.Column(db.String(1000))
    texts = db.relationship("ClassyText")
    labels = db.relationship("ClassyLabel")
Ejemplo n.º 12
0
class Status(db.Model):
    """This class is used for status table in database."""

    __tablename__ = 'statuses'

    id = db.Column(db.Integer, primary_key=True)
    status = db.Column(db.Text)
Ejemplo n.º 13
0
class Label(db.Model):
    '''标签表'''
    __tablename__ = 'label'
    label_id = db.Column(db.Integer, primary_key=True,
                         autoincrement=True)  #标签id
    label_name = db.Column(db.String(30))  # 标签名称
    article_infos = db.relationship('Article', backref='label', lazy='dynamic')
Ejemplo n.º 14
0
class BucketList(db.Model):
    """This class represents the bucketlist table"""

    __table__name = 'bucketlists'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255))

    date_created = db.Column(db.DateTime, default=db.func.current_timestamp())
    date_modified = db.Column(db.DateTime,
                              default=db.func.current_timestamp(),
                              onupdate=db.func.current_timestamp())

    def __init__(self, name):
        """Initializing with name"""
        self.name = name

    def save(self):
        db.session.add(self)
        db.session.commit()

    @staticmethod
    def get_all():
        return BucketList.query.all()

    def delete(self):
        db.session.delete(self)
        db.session.commit()

    def __refr__(self):
        return "<Bucketlist: {}>".format(self.name)
Ejemplo n.º 15
0
class Videos(db.Model):
    id = db.Column(db.Integer, unique=True, primary_key=True)
    title = db.Column(db.String(80), nullable=False)
    link = db.Column(db.String(200), nullable=False)

    def __repr__(self):
        return '<vid %r>' % self.id
Ejemplo n.º 16
0
class SpiderDB(db.Model):
    __tablename__ = 'spiders'

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer)
    name = db.Column(db.String)
    spider_type = db.Column(db.Integer)
Ejemplo n.º 17
0
class Category(db.Model):
    """This class is used for category table in database."""

    __tablename__ = 'category'

    id = db.Column(db.Integer, primary_key=True)
    category = db.Column(db.Text)
    favicon = db.Column(db.Text)
Ejemplo n.º 18
0
class Games(db.Model):
    id = db.Column(db.Integer, unique=True, primary_key=True)
    nick = db.Column(db.String(20), nullable=False)
    name = db.Column(db.String(20), nullable=False)
    dis = db.Column(db.String(200), nullable=False)

    def __repr__(self):
        return '<game %r>' % self.id
Ejemplo n.º 19
0
class Name(db.Model):
    __tablename__ = 'names'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), index=True, unique=True)

    def __repr__(self):
        return '<User %r>' % (self.nickname)
Ejemplo n.º 20
0
class UserModel(db.Model):
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String, unique=True)
    emailAddress = db.Column(db.String, unique=True)
    passwordSalt = db.Column(db.String)
    passwordHash = db.Column(db.String)
Ejemplo n.º 21
0
class Role(db.Model):
    __tablename__ = 'role'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100))
    users = db.relationship('User', backref='role', lazy=True)

    def serialize(self):
        return {"id": self.id, "name": self.name, "users": self.users}
Ejemplo n.º 22
0
class User(db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(200))
    email = db.Column(db.String(200), index=True, unique=True)

    def __repr__(self):
        return '<User %r>' % (self.name)
Ejemplo n.º 23
0
class User(db.Model):
    __tablename__ = 'users'

    user = db.Column(db.String(240), primary_key=True)
    name = db.Column(db.String(240))

    def __repr__(self):
        return '<User %r>' % (self.name)
Ejemplo n.º 24
0
class Phone(db.Model):
    __tablename__ = "phone"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    model = db.Column(db.String(32))
    price = db.Column(db.String(32))
    company_name = db.Column(
        db.String(20), db.ForeignKey('company.name'))  # 创建与company.name关联的外键
    company = db.relationship("Company", backref="phone_of_company")
Ejemplo n.º 25
0
class Company(db.Model):
    __tablename__ = "company"

    name = db.Column(db.String(20), primary_key=True)
    location = db.Column(db.String(20))

    def __repr__(self):
        return "name:{0} location:{1}".format(self.name, self.location)
Ejemplo n.º 26
0
class Service(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), unique=True, nullable=False, default='')
    description = db.Column(db.String(255), nullable=True, default='')
    admin_items = db.relationship('AdminItem', backref='service', lazy=True)
    client_items = db.relationship('ClientItem', backref='service', lazy=True)
    user_services = db.relationship("UserService",
                                    backref='service',
                                    lazy=True)
Ejemplo n.º 27
0
class Follower(db.Model):
    __tablename__ = 'followers'

    id = db.Column(db.Integer, primary_key=True)
    user = db.Column(db.String(240))
    followed_nickname = db.Column(db.String(240))

    def __repr__(self):
        return '<Followers %r>' % (self.followed)
Ejemplo n.º 28
0
class Role(db.Model):

    __tablename__ = 'tb_roles'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True, nullable=False, index=True)
    users = db.relationship('User', backref='role', lazy='dynamic')

    def __str__(self):
        return 'Role is: {}'.format(self.name)
Ejemplo n.º 29
0
class GMD(db.Model):
    __tablename__ = 'GMD'

    id = db.Column(db.Integer, primary_key=True)
    content = db.Column(db.String(200), nullable=False)
    date_created = db.Column(db.DateTime, default=datetime.utcnow)

    def __repr__(self):
        return '<Entry %r>' % self.id
Ejemplo n.º 30
0
class User(db.Model):
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), index=True, unique=True)
    steps = db.Column(db.Integer, index=True, unique=True)
    temp = db.Column(db.Integer, index=True, unique=True)

    def __repr__(self):
        return self.name