net/flask/manage-example.py

24 lines
355 B
Python
Raw Normal View History

2022-02-04 08:15:44 -05:00
from flask.cli import FlaskGroup
from project import app, db, User
cli = FlaskGroup(app)
@cli.command("create_db")
def create_db():
db.drop_all()
db.create_all()
db.session.commit()
@cli.command("seed_db")
def seed_db():
db.session.add(User(email="daniel@deflax.net"))
db.session.commit()
if __name__ == "__main__":
cli()