Exemple #1
0
class Article(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String)
    thumb = db.Column(db.String)
    intro = db.Column(db.String)
    author = db.Column(db.String)
    content = db.Column(db.Text)
    is_recommend = db.Column(db.Integer)
    pubdate = db.Column(db.DateTime, default=datetime.now)
    cate_id = db.Column(db.Integer, db.ForeignKey('category.cate_id'))
    comment = db.relationship('Comment')
Exemple #2
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    realname = db.Column(db.String)
    username = db.Column(db.String)
    password = db.Column(db.String)
    is_login = db.Column(db.Integer, default=0)
    last_login_time = db.Column(db.DateTime, nullable=True)
    created_at = db.Column(db.DateTime, default=datetime.utcnow)
    messages = db.relationship('Message')

    def hash_password(self, password):
        self.password = generate_password_hash(password)

    def validate_password(self, password):
        return check_password_hash(self.password, password)
Exemple #3
0
class User(db.Model):
    # 数据库字段映射到Python的变量
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String)
    password = db.Column(db.String)
    realname = db.Column(db.String)
    sex = db.Column(db.Integer)
    city = db.Column(db.String)
    hobby = db.Column(db.String)
    intro = db.Column(db.String)
    comment = db.relationship('Comment')

    def hash_password(self, password):
        self.password = generate_password_hash(password)

    def validate_password(self, password):
        return check_password_hash(self.password, password)
Exemple #4
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    realname = db.Column(db.String)
    username = db.Column(db.String, unique=True)
    password = db.Column(db.String)
    sex = db.Column(db.Integer)
    city = db.Column(db.String)
    education = db.Column(db.String)
    hobby = db.Column(db.String)
    is_single = db.Column(db.Integer)
    message = db.relationship('Message')

    def hash_password(self, password):
        self.password = generate_password_hash(password)

    def validate_password(self, password):
        return check_password_hash(self.password, password)
Exemple #5
0
class Category(db.Model):
    cate_id = db.Column(db.Integer, primary_key=True)
    # unique=True,表示此字段值不能重复
    cate_name = db.Column(db.String, unique=True)
    cate_order = db.Column(db.Integer, default=0)
    articles = db.relationship("Article")