Пример #1
0
from flask import current_app
from flask.cli import FlaskGroup

from . import make_app
from .api.utils import get_user
from .ext import cache
from .migrations import MIGRATIONS, run_migration
from .models import MODELS, User, db


def create_app(info):
    return make_app('dev')


cli = FlaskGroup(create_app=create_app)
cli.help = 'This is a management script for the Devlog application.'


@cli.group(name='db', help='database management commands')
def db_ops():
    pass


@db_ops.command(name='init', help='initialize missing database objects')
def db_init():
    db.create_tables(MODELS)


@db_ops.command(name='clear', help='remove all database objects')
def db_clear():
    db.drop_tables(MODELS)
Пример #2
0
from dotenv import find_dotenv, load_dotenv
from flask.cli import FlaskGroup

from .app import make_app
from .models import Post, RevokedToken, Stream, User, db

load_dotenv(find_dotenv())


def create_app(info):
    return make_app()


cli = FlaskGroup(create_app=create_app)
cli.help = 'Management script for Microblog backend application'


@cli.group(name='db')
def db_ops():
    pass


@db_ops.command(name='init')
def db_init():
    db.create_tables([User, Stream, Post, RevokedToken])


if __name__ == '__main__':
    cli()