flask-migrate

一、下载

pip3 install -i https://pypi.douban.com/simple flask-migrate

注意:依赖 flask-script

二、使用

manage.py

from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from 项目名称 import create_app
from 项目名称 import db

app = create_app()
manager = Manager(app)
migrate = Migrate()
migrate.init_app(app, db)
""" # 数据库迁移命名 python manage.py db init # 生成表 使用一次即可 python manage.py db migrate # makemirations python manage.py db upgrade # migrate """ manager.add_command('db', MigrateCommand) if __name__ == '__main__': # app.run() manager.run()
posted @ 2019-10-02 23:17  市丸银  阅读(141)  评论(0编辑  收藏  举报