Models.py#coding:utf8fromflaskimportFlaskfromflask_sqlalchemyimportSQLAlchemyapp=Flask(__name__)#實例化app.config["SQLALCHEMY_DATABASE_URI"]="mysql://roo... ...
Models.py #coding:utf8 fromflaskimportFlask fromflask_sqlalchemyimportSQLAlchemy app=Flask(__name__) #實例化 app.config["SQLALCHEMY_DATABASE_URI"]="mysql://root:[email protected]: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