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) content = db.Column(db.Text) author = db.Column(db.String) is_recommend = db.Column(db.Integer) pubdate = db.Column(db.DateTime, default=datetime.utcnow) cate_id = db.Column(db.Integer, db.ForeignKey("category.cate_id"))
class User(db.Model): 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) mylike = db.Column(db.String) city = db.Column(db.String) intro = db.Column(db.String)
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)
class Comment(db.Model): id = db.Column(db.Integer, primary_key=True) audited = db.Column(db.Integer) article_id = db.Column(db.Integer, db.ForeignKey('article.id')) author = db.Column(db.String, db.ForeignKey('user.username')) time = db.Column(db.DateTime, default=datetime.now) content = db.Column(db.String)
class Article(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String) intro = db.Column(db.String) content = db.Column(db.Text) author = db.Column(db.String) pubdate = db.Column(db.DateTime, default=datetime.utcnow)
class User(db.Model): 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) mylike = db.Column(db.String) city = db.Column(db.String) intro = db.Column(db.String) def hash_password(self, password): self.password = generate_password_hash(password) def validate_password(self, password): return check_password_hash(self.password, password)
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)
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)
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")
class Alert(db.Model): alert_id = db.Column(db.Integer, primary_key=True) alert_time = db.Column(db.DateTime, default=datetime.now) alert_content = db.Column(db.String)
class Message(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) send_time = db.Column(db.DateTime, default=datetime.now) content = db.Column(db.String, nullable=True) from_user = db.Column(db.String, db.ForeignKey('user.username')) to_user = db.Column(db.String)
class Message(db.Model): id = db.Column(db.Integer, primary_key=True) body = db.Column(db.Text, nullable=False) created_at = db.Column(db.DateTime, default=datetime.utcnow, index=True) from_author_id = db.Column(db.Integer, db.ForeignKey('user.id')) to_author_id = db.Column(db.Integer, default=0)