class UserInfo(db.Model): __tablename__ = 'user_info' __table_args__ = {'mysql_collate': 'utf8_general_ci'} openid = db.Column(db.String(50), primary_key=True) nickName = db.Column(db.String(20)) gender = db.Column(db.String(5)) city = db.Column(db.String(20)) province = db.Column(db.String(20)) def __repr__(self): return '<UserInfo {}>'.format(self.openid)
class User(db.Model): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), nullable=False, unique=True, index=True) password = db.Column(db.String(20)) gender = db.Column(db.Enum(Gender), default='unknow') city = db.Column(db.String(20), nullable=False) birthday = db.Column(db.Date, default='1990-01-01') bio = db.Column(db.Text)
class Users(db.Model): # 定义表名字 __tablename__ = 'users' # id name age sex # id代表生成的table的一列,name,age,sex以此类推 # db.Integer 列的数据类型 id = db.Column(db.Integer,primary_key=True) name = db.Column(db.String(50),unique=True) age = db.Column(db.Integer) sex = db.Column(db.Boolean) address = db.Column(db.String(90))
class Students(db.Model): __tablename__ = 'people' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50)) sex = db.Column(db.Boolean) age = db.Column(db.Integer) class_id = db.Column(db.Integer, db.ForeignKey('class.id'))
class Article(db.Model): '''文章''' __tablename__ = 'article' id = db.Column(db.Integer, primary_key=True) uid = db.Column(db.Integer, nullable=False, index=True) title = db.Column(db.String(32), nullable=False, index=True) content = db.Column(db.Text) created = db.Column(db.DateTime, nullable=False)
class User(db.Model): __table__name = 'users' id = db.Column(db.String, primary_key=True) name = db.Column(db.String()) def save(self): db.session.add(self) db.session.commit() @classmethod def get_all(cls): return User.query.all()
class Classes(db.Model): __tablename__ = 'class' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50)) classNum = db.Column(db.Integer) class_ship = relationship('Students', backref='cla')