reconciler: Format BQL query

This commit is contained in:
Ben Sturmfels 2023-02-11 15:25:44 +11:00
parent e764f3d0ef
commit 07d7737bd0
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0

View file

@ -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])