Added 'restart' to start over
This commit is contained in:
parent
763427017b
commit
590590c8e5
1 changed files with 25 additions and 0 deletions
25
schmeckels/restart.py
Normal file
25
schmeckels/restart.py
Normal 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()
|
Loading…
Add table
Reference in a new issue