From 07d7737bd022d185db0a4e75296745c817b485e5 Mon Sep 17 00:00:00 2001 From: Ben Sturmfels Date: Sat, 11 Feb 2023 15:25:44 +1100 Subject: [PATCH] reconciler: Format BQL query --- .../reconcile/statement_reconciler.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/conservancy_beancount/reconcile/statement_reconciler.py b/conservancy_beancount/reconcile/statement_reconciler.py index 034d33a..17dc912 100644 --- a/conservancy_beancount/reconcile/statement_reconciler.py +++ b/conservancy_beancount/reconcile/statement_reconciler.py @@ -691,7 +691,19 @@ def main(arglist: Optional[Sequence[str]] = None, entries, _, options = loader.load_file(args.beancount_file) # String concatenation looks bad, but there's no SQL injection possible here # because BQL can't write back to the Beancount files. I hope! - query = f'SELECT filename, META("lineno") AS line, META("bank-statement") AS bank_statement, date, number(cost(position)), payee, ENTRY_META("entity") as entity, ANY_META("check-id") as check_id, narration where account = "{args.account}" and date >= {begin_date} and date <= {end_date}' + query = f""" + SELECT filename, + META("lineno") AS line, + META("bank-statement") AS bank_statement, + date, + number(cost(position)), + payee, + ENTRY_META("entity") as entity, + ANY_META("check-id") as check_id, + narration + WHERE account = "{args.account}" + AND date >= {begin_date} + AND date <= {end_date}""" _, result_rows = run_query(entries, options, query) books_trans = sort_records([standardize_beancount_record(row) for row in result_rows])