Example #1
0
def main(args):
    if '--debug' in args:
        logging.getLogger('').setLevel(logging.DEBUG)

    db.init()

    with db.tx() as session:
        session.query(Transaction)\
            .update({'member_id': None, 'type': None})
Example #2
0
    def test_basic_successful_tx(self):
        with db.tx() as tx:
            tx.do("INSERT INTO foo (foo_id, value) VALUES (2, 'bar')")
            tx.do("INSERT INTO foo (foo_id, value) VALUES (3, 'baz')")

        rows = db.items("SELECT * FROM foo ORDER BY foo_id")
        assert len(rows) == 3
        for index, row in enumerate(rows):
            assert row.foo_id == index + 1
        assert rows[2].value == "baz"
Example #3
0
File: test_db.py Project: palbee/db
    def test_basic_successful_tx(self):
        with db.tx() as tx:
            tx.do("INSERT INTO foo (foo_id, value) VALUES (2, 'bar')")
            tx.do("INSERT INTO foo (foo_id, value) VALUES (3, 'baz')")

        rows = db.items("SELECT * FROM foo ORDER BY foo_id")
        assert len(rows) == 3
        for index, row in enumerate(rows):
            assert row.foo_id == index + 1
        assert rows[2].value == "baz"
Example #4
0
    def test_basic_rollback(self):
        try:
            with db.tx() as tx:
                tx.do("INSERT INTO foo (foo_id, value) VALUES (2, 'bar')")
                tx.do("BAD STATEMENT")
        except Exception:
            pass

        row = db.item("SELECT * FROM foo")
        assert row.foo_id == 1
        assert row.value == "foo"
Example #5
0
File: test_db.py Project: palbee/db
    def test_basic_rollback(self):
        try:
            with db.tx() as tx:
                tx.do("INSERT INTO foo (foo_id, value) VALUES (2, 'bar')")
                tx.do("BAD STATEMENT")
        except Exception:
            pass

        row = db.item("SELECT * FROM foo")
        assert row.foo_id == 1
        assert row.value == "foo"
Example #6
0
def get_transactions(force=False, tan_callback=hbci_client.terminal_tan_callback):
    with db.tx() as session:
        last_load: Status = session.query(Status)\
            .filter_by(key=LAST_LOAD)\
            .first()
        if last_load:
            logging.info("Last load was at %s", last_load.value_dt)
            if not force and last_load.value_dt + load_interval_max > datetime.utcnow():
                logging.info("Quite recent, not loading new txs")
                return
        else:
            last_load = Status(key=LAST_LOAD)

        logging.info("Loading fresh transactions")
        load_transactions(session, last_load, tan_callback)
Example #7
0
def main(args, to=sys.stdout, months=12):
    if '--debug' in args:
        logging.getLogger('').setLevel(logging.DEBUG)

    db.init()

    end_month = date.today()
    if end_month.day <= config.report_month_end:
        end_month = end_month - relativedelta(months=1)
    end_month = end_month.replace(day=1)

    start_month = end_month - relativedelta(months=months)

    with db.tx() as session:
        members = session.query(Member) \
            .order_by(Member.last_name, Member.first_name)
        members_table(session, members, start_month, end_month, to)