Created
June 15, 2022 05:49
-
-
Save twyle/84987f2b12673a9a99cedca8a999f651 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""This module executes the application.""" | |
from flask.cli import FlaskGroup | |
from api import app, db | |
from api.blueprints.default.models import User | |
cli = FlaskGroup(app) | |
@cli.command('create_db') | |
def create_db(): | |
"""Create the database and all the tables.""" | |
db.drop_all() | |
db.create_all() | |
db.session.commit() | |
@cli.command('seed_db') | |
def seed_db(): | |
"""Add two users.""" | |
db.session.add(User(email='[email protected]')) | |
db.session.add(User(email='[email protected]')) | |
db.session.commit() | |
if __name__ == '__main__': | |
cli() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment