from flask import Flask
from flask_script import Manager
from sansa import db
from flask_migrate import Migrate,MigrateCommand
app = Flask(__name__)
manager = Manager(app)
migrate = Migrate(db=db)
migrate.init_app(app)
"""
数据库迁移命名:
python manage.py db init 每个项目执行一次 他负责生成迁移包
python manage.py db migrate 生成迁移文件
python manage.py db upgrade 执行上升操作(执行迁移信息)
python manage.py db downgrade 执行下降操作
python manage.py db --help 查看帮助文档
"""
manager.add_command('db',MigrateCommand)
@manager.command
def custom(arg):
"""
自定义命令
python manager.py custom 123
:param arg:
:return:
"""
print(arg)
@manager.option('-n', '--name', dest='name')
@manager.option('-u', '--url', dest='url')
def cmd(name, url):
"""
自定义命令
执行:python manager.py cmd -n wupeiqi -u http://www.oldboyedu.com
:param name:
:param url:
:return:
"""
print(name, url)
if __name__ == '__main__':
# app.run()
manager.run()