1 classRole (usermixin, DB. Model):2 __tablename__='Role'3ID = db. Column (db. Integer, primary_key=True)4Username = db. Column (db. String (nullable=),True)5Role = db. Column (db. String (nullable=),True)6Password = db. Column (db. String (nullable=),True)7Password_hash = db. Column (db. String (+), nullable=True)8 9Role_art = Db.relationship ('article', backref='Roleart')Tenrole_com = Db.relationship ('Comment', backref='rolecom') One A @property - defpassword (self): - RaiseAttributeerror ('password is not readable attribute') #没有可读的明文密码属性 the - @password. Setter #设置 hashed password value - defpassword (self, password): -Self.password_hash =generate_password_hash (password) + - defVerify_password (self, password): + returnCheck_password_hash (self.password_hash, password)
Using SQLAlchemy to manipulate the properties of MySQL black technology