flask-sqlalchemy使用命令创建数据库

# 启动文件
from
flask_script import Manager,Server from flask_migrate import MigrateCommand,Migrate from rbac import create_app,db app = create_app() manager = Manager(app) migrate = Migrate(app,db) manager.add_command("runserver",Server()) manager.add_command("db",MigrateCommand) if __name__ == '__main__': manager.run()
# 启动文件启动自动触发
from
flask import Flask from config.setting import BaseConfig #导入flask-sqlalchemy from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() from .views.user import user # 导入models中的表 from .model.models import * def create_app(): app = Flask(__name__) app.register_blueprint(user) db.init_app(app) return app

执行命令:
初次:

  python manage.py db init
  python manage.py db migrate
  python manage.py db upgrade

 

posted @ 2018-01-14 20:06  一石数字欠我15w!!!  阅读(1227)  评论(0编辑  收藏  举报