Models.py #coding:utf8 fromflaskimportFlask fromflask_sqlalchemyimportSQLAlchemy app=Flask(__name__) #实例化 app.config["SQLALCHEMY_DATABASE_URI"]="mysql://root:toor@127.0.0.1:3306/movie"app.config["SQLALCHEMY_TRACK_MODIFICATION"]=True db=SQLAlchemy(app) #会员 classUser(db.Model): __tablename__=="user"id=db.Column(db.Interger,primary_key=True) name=db.Column(db.String(100),unique=True) pwd=db.Column(db.String(100)) email=db.Column(db.String(100),unique=True) phone=db.Column(db.String(11),unique=True) info=db.Column(db.Text) face=db.Column(db.string(255)) addtime=db.Column(db.DateTime,index=True,default=datetime.utcnow) uuid=db.Column(db.String(255),unique=True) def__repr__(self):return"<User%r>"%self.name #会员登录日志 classUserlog(db.Model): __tablename__="userlog"id=db.Column(db.INterger,db.ForeignKey('user.id')) ip=db.Column(db.String(100)) #登录ip. addtime=db.Column(db.DateTime,index=True,default=datetime.utcnow) def__repr__(self):return"<Userlog%r>"%self.id
作者:kailicard
原文链接:https://www.cnblogs.com/kk328/p/10187814.html