flask 脚本迁移语句

1、数据库迁移语句

python manager.py db init

python manger.py db migrate

python manager.py db upgrade

2、 create_app()


def create_app():
app = Flask(__name__)
CORS(app,resources=r'/*')
app.config.from_object('app.config.setting')
app.config.from_object('app.config.secure')

register_blueprint(app)
register_plugin(app)

return app

3、 manager.py

from flask_script import Manager
from app.app import create_app
from app.models.base import db
from flask_migrate import Migrate, MigrateCommand

app = create_app()
migrate = Migrate(app, db)
manager = Manager(app)
from app.models.detect import Detect
from app.models.case import Case
manager.add_command('db', MigrateCommand)
manager.run()




posted @ 2021-06-17 14:38  我要成为女技术宅  阅读(48)  评论(0编辑  收藏  举报