#!/usr/bin/env python from flask_migrate import Manager, MigrateCommand from website import app manager = Manager(app) manager.add_command('db', MigrateCommand) if __name__ == '__main__': manager.run()
from flask import Flask from flask_migrate import Migrate, Manager, MigrateCommand from app.model.base import db app = Flask(__name__) app.config.from_pyfile('secure.py') app.config.from_pyfile('settings.py') migrate = Migrate(app, db) manager = Manager(app) manager.add_command('db', MigrateCommand) if __name__ == '__main__': manager.run()
#Importujeme import root from root import models from flask_migrate import Migrate, Manager, MigrateCommand app = root.app #Nastavíme novou relativní cestu k databázi, jelikož script nespouštíme ze složky root app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///databaze.sqlite3" #Provedeme inicializaci migrate = Migrate(app, root.db) manager = Manager(app) #Přidáme přikaz pro manager manager.add_command("db", MigrateCommand) #Přikaz spustíme, pokud byl script spuštěn if __name__ == "__main__": manager.run()
else: return fn(*args, **kwargs) return wrapper ####Database#### app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://a:b@c:3306/LKNU' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db = SQLAlchemy(app) migrate = Migrate(app, db) manager = Manager(app) manager.add_command( 'db', MigrateCommand ) # command 'db' dapat menjalankan semua command MigrateCommand ###########Middleware############# @app.after_request def after_request(response): try: requestData = request.get_json() except Exception as e: requestData = request.args.to_dict() app.logger.warning( "REQUEST_LOG\t%s", json.dumps({ 'uri': request.full_path, 'code': response.status,
from flask_script import Shell, Server from flask_migrate import Manager, MigrateCommand from services.config import db, migrate from services.app import app from services.resources import Calculation manager = Manager(app) manager.add_command('db', MigrateCommand) manager.add_command('runserver', Server(host='0.0.0.0', port=5000)) if __name__ == '__main__': # manager.run() app.run(debug=True)
# -*- coding: UTF-8 -*- import os from flask_migrate import Migrate, Manager, MigrateCommand from flask_script import Shell from app import create_app, db from app.models import User, Role app = create_app(os.getenv('FLASK_CONFIG') or 'default') migrate = Migrate(app, db) manager = Manager(app) def make_shell_context(): return dict(db=db, User=User, Role=Role) manager.add_command("shell", Shell(make_context=make_shell_context)) manager.add_command('db', MigrateCommand) @manager.command def test(): """Run the unit tests.""" import unittest tests = unittest.TestLoader().discover('tests') unittest.TextTestRunner(verbosity=2).run(tests) if __name__ == '__main__': manager.run()
from . import create_app from flask_script import Command from flask_migrate import MigrateCommand, Manager class Init_Admin(Command): def run(self): from .models.Admin import Administrator Administrator.init() manager = Manager(create_app) manager.add_command('init_admin', Init_Admin) if __name__ == '__main__': manager.run()
from flask_migrate import Migrate, Manager, MigrateCommand from flask_script import Shell from aggregation import create_app, db from aggregation import settings from aggregation.api.commonds.shell import make_context if __name__ == '__main__': app = create_app(settings) app.secret_key = settings.SECCRET_KEY manager = Manager(app) migrate = Migrate(app, db) from aggregation.api.modules.transactions.models import Transaction manager.add_command('db', MigrateCommand) manager.add_command('shell', Shell(make_context=make_context)) manager.run()
def init_app(app): migrate.init_app(app, db) manager = Manager(app) manager.add_command("db", MigrateCommand)