Skip to content

Instantly share code, notes, and snippets.

@twyle
Created June 15, 2022 05:49
Show Gist options
  • Save twyle/84987f2b12673a9a99cedca8a999f651 to your computer and use it in GitHub Desktop.
Save twyle/84987f2b12673a9a99cedca8a999f651 to your computer and use it in GitHub Desktop.
# -*- 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='test@example.com'))
db.session.add(User(email='test1@example.com'))
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