From 590590c8e55bd1f4aea446c4ae4b80e558025ead Mon Sep 17 00:00:00 2001 From: fleaz Date: Fri, 24 Feb 2023 00:02:50 +0100 Subject: [PATCH] Added 'restart' to start over --- schmeckels/restart.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 schmeckels/restart.py diff --git a/schmeckels/restart.py b/schmeckels/restart.py new file mode 100644 index 0000000..5009515 --- /dev/null +++ b/schmeckels/restart.py @@ -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()