Example #1
0
# 管理程序启动
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from info import creat_app, db, models
from config import DevelopmentConfig, ProductionConfig

# 通过create_app,传递不同的配置信息,来实现manager以不同模式来启动
app = creat_app(DevelopmentConfig)

# 创建Manage
manager = Manager(app)

# 创建迁移对象
Migrate(app, db)

# 给Manager绑定迁移命令
manager.add_command('db', MigrateCommand)

if __name__ == '__main__':
    print(app.url_map)
    manager.run()
Example #2
0
from flask import session
from flask_script import Manager
from flask_migrate import MigrateCommand

from info import creat_app

app = creat_app("dev")
# 创建管理器
mgr = Manager(app)

# 使用管理器生成迁移命令
mgr.add_command("mc", MigrateCommand)

if __name__ == '__main__':
    mgr.run()
Example #3
0
import logging

from flask.ext.migrate import Migrate, MigrateCommand
from flask.ext.script import Manager
from info import db, creat_app

app = creat_app('development')


# 视图函数抽取到modules  蓝图
# @app.route('/')
# def index():
#     # 测试打印日志
#     logging.debug('测试debug')
#     logging.warning('测试warning')
#     logging.error('测试error')
#     logging.fatal('测试fatal')
#
#     # flask中用如下方法打印日志
#     # current_app.logger.error('测试error')
#
#     return 'Hello World!'


manager = Manager(app)
Migrate(app, db)
manager.add_command('db', MigrateCommand)

if __name__ == '__main__':
    manager.run()
Example #4
0
from info import creat_app, db
from flask_script import Manager
from flask_migrate import MigrateCommand, Migrate
from info import models

app = creat_app("develop")
manager = Manager(app)
Migrate(app, db)
manager.add_command('db', MigrateCommand)

if __name__ == '__main__':
    manager.run()
Example #5
0
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# author:caozy time:18-12-16

from flask import current_app
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from info import creat_app, db
from info import models

# 用Manager类管理app
from info.models import User

app = creat_app()
manager = Manager(app)
# 迁移app和db
Migrate(app=app, db=db)
# 将迁移指令db添加到Manager类中
manager.add_command('db', MigrateCommand)


# 使用flask-script扩展添加命令行相关逻辑
@manager.option('-n', '-name', dest='name')
@manager.option('-p', '-password', dest='password')
def createsuperuser(name, password):
    '''创建管理员'''
    if not all([name, password]):
        print('参数不足')
        return
    user = User()
    user.mobile = name
Example #6
0
import logging

from flask import session, current_app
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand

from info import creat_app, db

#创建app,配置不同环境的配置
app = creat_app('devolopment')
#使用项目管理器管理app
manage = Manager(app)
#设置迁移Migrate对象,将app与db相关联
migrate = Migrate(app, db)
#将迁移命令添加到manager对象中
manage.add_command('db', MigrateCommand)

if __name__ == "__main__":
    manage.run()
Example #7
0
# -*-coding:utf-8-*-
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
from info import creat_app, db, models

app = creat_app('develop')

# 设置迁移命令
manage = Manager(app)
Migrate(app, db)
manage.add_command('db', MigrateCommand)

if __name__ == '__main__':

    manage.run()
Example #8
0
from flask import Flask, session
from flask.ext.sqlalchemy import SQLAlchemy
import redis
from flask_wtf.csrf import CSRFProtect
from flask_session import Session
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
from config import Config
from info import creat_app, db

app = creat_app('1')

zhangsan = Manager(app)
Migrate(app, db)
zhangsan.add_command('db', MigrateCommand)

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