flask_migrate 帮助我们做数据库的迁移,和Django中的很相似。

from crm import create_app,db
from flask_script import Manager
#做数据库的迁移
from flask_migrate import Migrate,MigrateCommand

app = create_app()
manager = Manager(app)

Migrate(app,db)
'''
数据库迁移命令:
python manage.py db init (只需要执行一遍) Django中
python manage.py db migrate ---> makemigration
python manage.py db upgrade ----> migrate 
'''
manager.add_command('db',MigrateCommand)

if __name__ == "__main__":
# app.run()
manager.run()

  

posted on 2019-10-19 11:42  小辉python  阅读(158)  评论(0编辑  收藏  举报