Skip to main content

Beancount INquiry

A CLI tool to INject parameters into Beancount queries specified in your ledger

Usage

Beancount INquiry will inject parameters into query directives specified in your ledger file using pythons .format function, and so uses the same syntax. Here is an example query directive with two parameters:

2025-01-01 query "balance" "SELECT date, account, sum(number) as total WHERE account ~ '{}' AND date >= {} ORDER BY account"

And then pass in the ledger, the name of the query, and the list of parameters

bean-inquiry ledger.beancount balance Assets 2014-05-01

You can also use indexed placeholders:

2025-01-01 query "balance" "SELECT date, {0}, sum(number) as total WHERE {0} ~ '{1}' AND date >= {2} ORDER BY {0}"
...
bean-inquiry ledger.beancount balance account Assets:Bank 2025-05-01

And named placeholders, with parameter keys separated with a colon:

2025-01-01 query "balance" "SELECT date, {select}, sum(number) as total WHERE {select} ~ '{account}' AND date >= {date} ORDER BY {select}"
...
bean-inquiry ledger.beancount balance select:account account:Assets:Bank date:2025-05-01

See the --help for more options

bean-inquiry --help

Installation

There are two different versions of Beancunt INquiry, the CLI tool and the script, the main difference being that the CLI tool can run stand-alone and has beanquery as a dependency, and the script does not have dependencies but needs bean-query installed on your system and in your PATH. Also currently the script can only run query directives that are on a single line in your ledger, whereas the CLI tool can run query directives that traverse multiple lines.

CLI

Pipx (recommended)

Install using pipx from PyPi

pipx install bean-inquiry
bean-inquiry --help

Build from source using pipx

Clone this repository and install systemwide using pipx:

git clone https://github.com/aleyoscar/beancount-inquiry.git
cd beancount-inquiry
pipx install .
bean-inquiry --help

Run using poetry

Clone this repository and run using poetry

git clone https://github.com/aleyoscar/beancount-inquiry.git
cd beancount-inquiry
poetry install
poetry run bean-inquiry

Script

Does not need beanquery, but does need the bean-query executable installed on your system and in your PATH. Simply download bean-inquiry.py or clone this repository and run the script bean-inquiry.py in the root project folder:

python bean-inquiry.py --help

Dependencies

This project uses beancount to parse the ledger and beanquery for running the queries.

Metadata

Release files for bean-inquiry 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bean-inquiry 0.3.0
File Size Uploaded
bean_inquiry-0.3.0.tar.gz 16.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bean-inquiry 0.3.0
File Interpreter ABI Platform
bean_inquiry-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 33.4 kB

Release files / bean_inquiry-0.3.0.tar.gz

Download URL bean_inquiry-0.3.0.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2757e7b1e3f25b14a851a4045a9489829f8696a44e4c8c5616c91d7633c6a1a6
BLAKE2b-256 checksum
How to use checksums
bcdc2db518e60e40230e43e83a6d275ec1a651eac12294449c1efc0ee6aeb796
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.0 CPython/3.11.9 Windows/10

Release files / bean_inquiry-0.3.0-py3-none-any.whl

Download URL bean_inquiry-0.3.0-py3-none-any.whl
Size 17.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cfe89500f3e0fe0c4b6fe6b1eb62360a78cc3a84695ba4a020ca0e19a1e9695f
BLAKE2b-256 checksum
How to use checksums
22a8d891914ba2c281df1fcb5532d3c33b9939e4de5a2319baff4b25fe505d23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.0 CPython/3.11.9 Windows/10

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page