flask 更新表结构

manager.py文件:

#coding=utf-8
from flask_migrate import Migrate,MigrateCommand
from flask_script import Shell,Manager
from app import app
from app import db

manager = Manager(app)
#第一个参数是Flask的实例,第二个参数是Sqlalchemy数据库实例
migrate = Migrate(app,db)
#manager是Flask-Script的实例,这条语句在flask-Script中添加一个db命令
manager.add_command('db',MigrateCommand)

if __name__ == '__main__':
  manager.run()

执行的命令:

python manage.py db init
python manage.py db migrate -m "change db tables"
python manage.py db upgrade

你可能感兴趣的:(flask 更新表结构)