Skip to main content

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

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bean_inquiry-0.3.0.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bean_inquiry-0.3.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file bean_inquiry-0.3.0.tar.gz.

File metadata

  • Download URL: bean_inquiry-0.3.0.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.0 CPython/3.11.9 Windows/10

File hashes

Hashes for bean_inquiry-0.3.0.tar.gz
Algorithm Hash digest
SHA256 2757e7b1e3f25b14a851a4045a9489829f8696a44e4c8c5616c91d7633c6a1a6
MD5 b27bf6f7329b1f3d227cbc254a4bf203
BLAKE2b-256 bcdc2db518e60e40230e43e83a6d275ec1a651eac12294449c1efc0ee6aeb796

See more details on using hashes here.

File details

Details for the file bean_inquiry-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: bean_inquiry-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.0 CPython/3.11.9 Windows/10

File hashes

Hashes for bean_inquiry-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cfe89500f3e0fe0c4b6fe6b1eb62360a78cc3a84695ba4a020ca0e19a1e9695f
MD5 9722e357dce185b73be0eef7ed94963b
BLAKE2b-256 22a8d891914ba2c281df1fcb5532d3c33b9939e4de5a2319baff4b25fe505d23

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page