Exemple #1
0
class User(db.Model,UserMixin):
    __tablename__ = 'user'
    uid = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(30), nullable=False)
    password = db.Column(db.String(128), nullable=False)
    gender = db.Column(db.Integer)

    # 如果表的主键不是id,需要重写这个方法
    def get_id(self):
        try:
            return text_type(self.uid) # 返回主键
        except AttributeError:
            raise NotImplementedError('No `id` attribute - override `get_id`')
Exemple #2
0
class Article(db.Model):
    aid = db.Column(db.Integer, primary_key=True, autoincrement=True)
    title = db.Column(db.String(100), nullable=True)
    content = db.Column(db.String(10000))
    create_time = db.Column(db.DateTime, default=datetime.now)
    cid = db.Column(db.Integer,
                    db.ForeignKey("category.cid", ondelete="CASCADE"))
    hits = db.Column(db.Integer, default=0)
    replies = db.Column(db.Integer, default=0)
    picture = db.Column(db.String(300))
    __tablename__ = 'article'
Exemple #3
0
class User(db.Model, UserMixin):
    uid = db.Column(db.Integer, primary_key=True, autoincrement=True)
    username = db.Column(db.String(30), nullable=False, unique=True)
    password = db.Column(db.String(128), nullable=False)
    phone = db.Column(db.String(11))
    email = db.Column(db.String(200))
    portrait = db.Column(db.String(300))
    regtime = db.Column(db.DateTime)
    isforbid = db.Column(db.Boolean, default=False)

    __tablename__ = 'user'

    # 如果表的主键不是id,需要重写这个方法
    def get_id(self):
        try:
            return text_type(self.uid)  # 返回主键
        except AttributeError:
            raise NotImplementedError('No `id` attribute - override `get_id`')
Exemple #4
0
class Mark(db.Model):
    mid = db.Column(db.Integer, primary_key=True, autoincrement=True)
    content = db.Column(db.String(1000))
    create_time = db.Column(db.DateTime)
    uid = db.Column(db.Integer, db.ForeignKey('user.uid'))
Exemple #5
0
class Tag(db.Model):
    tid = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(30), nullable=True)
    aid = db.Column(db.Integer, db.ForeignKey("article.aid"))
Exemple #6
0
class Category(db.Model):
    cid = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(100), nullable=False, unique=True)
    num = db.Column(db.Integer, default=0)
    __tablename__ = "category"