app.py
from flask import Flask
import click from flask_sqlalchemy import SQLAlchemy
app = Flask(name) db = SQLAlchemy(app) @app.cli.command() @click.option('--drop', is_flag=True, help='Create after drop.') def initdb(drop): """Initialize the database.""" if drop: db.drop_all() db.create_all() click.echo('Initialized database.')
if name == 'main': app.run()
执行:
flask initdb