Added 'restart' to start over

This commit is contained in:
fleaz 2023-02-24 00:02:50 +01:00
parent 763427017b
commit 590590c8e5
No known key found for this signature in database
GPG key ID: AED15F8FDD04D083

25
schmeckels/restart.py Normal file
View file

@ -0,0 +1,25 @@
#! /usr/bin/env python3
import re
import sys
import click
import colorful as cf
from schmeckels.helper import create_tag, get_rules, get_session
from schmeckels.models import Tag, Transaction
@click.command(name="restart")
def command():
input("This will DELETE all tags and remove all sorting! You sure?")
session = get_session()
allTransactions = session.query(Transaction).all()
for transaction in allTransactions:
transaction.tags = []
session.bulk_save_objects(allTransactions)
session.query(Tag).delete()
session.commit()