1
0
Export ledger files into a SQLite database
This repository has been archived on 2023-12-27. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
2022-07-25 15:13:07 -07:00
.devcontainer Work in progress parsing output from hledger 2022-07-22 10:06:06 -07:00
.github/workflows Fix docker image tags 2022-07-24 08:00:38 -07:00
.vscode Work in progress parsing output from hledger 2022-07-22 10:06:06 -07:00
data Preliminary version seemingly functional 2022-07-22 14:59:19 -07:00
src Add description to output tables 2022-07-25 15:13:07 -07:00
.gitignore Work in progress parsing output from hledger 2022-07-22 10:06:06 -07:00
docker-entrypoint.sh Run export on a cron schedule 2022-07-23 09:39:20 -07:00
Dockerfile Fix bug in container entry command 2022-07-24 20:52:25 -07:00
LICENSE Initial commit 2022-07-22 08:22:38 -07:00
README.md Run export on a cron schedule 2022-07-23 09:39:20 -07:00

Ledger SQLite

A simple containerized utility which creates a SQLite database from the contents of a ledger file. Uses hledger to output JSON which is then transformed into a database schema.

Exports are not designed to be consistent across iterations. It is recommended that you start from a fresh databse every export.

Usage

The default configuration is to run in a long-lived mode where the conversion will happen on a regular schedule defined by cron. You can use crontab guru to build the value for the CRONTAB_SCHEDULE variable.

docker run \
    --name ledger-sqlite \
    --env "LEDGER_FILE=/data/journal.ledger" \
    --env "OUTPUT_FILE=/data/journal.sqlite" \
    --env "CRONTAB_SCHEDULE=0 15 * * *" \
    -v /path/to/data:/data \
    ghcr.io/tgrosinger/ledger-sqlite:latest

Alternatively, a single conversion can be performed and the container will exit when complete. This can also be useful for debugging as the logs are easier to retrieve.

docker run \
    --rm
    --env "LEDGER_FILE=/data/journal.ledger" \
    --env "OUTPUT_FILE=/data/journal.sqlite" \
    -v /path/to/data:/data \
    --entrypoint python \
    ghcr.io/tgrosinger/ledger-sqlite:latest \
    /code/main.py