You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
660 B
Python

import click
from quart import Blueprint, current_app
from myapp.models import MyThing
from myapp.factory import db
bp = Blueprint('filters', 'filters')
@bp.cli.command('init')
def init():
import app.models
db.create_all()
@bp.cli.command('delete')
@click.argument('thing_id')
def delete(thing_id):
thing = MyThing.query.get(thing_id)
if thing:
db.session.delete(thing)
db.session.commit()
click.echo(f'MyThing {thing.id} was deleted')
else:
click.echo('MyThing ID does not exist')
@bp.cli.command('list')
def list_things():
thing = MyThing.query.all()
for i in thing:
click.echo(i.id)