gt is a command line tool that performs convenient actions on a
gnucash sqlite3 database.
warning: gt is experimental and can destroy your gnucash sqlite3 database
gt is not associated with the gnucash project in anyway. There is no
guarantee that any action performed by gt will not corrupt, destroy or
modify in an unexpected way a gnucash sqlite3 database. If you choose to
use gt, please backup your gnucash sqlite3 database before doing so.
I had completed a migration of transactions into gnucash and needed a way to bulk edit many transactions. At the time, there was no support for bulk editing transactions within gnucash. There are libraries that provide access to the gnucash sqlite3 database though I had written enough code that worked on the gnucash sqlite3 database to be comfortable in writing my own tool.
Build:
$ go build -o ./gt ./cmd/gt/main.go
The gt config file defaults to ~/.gt.json which supports these
options:
{
"gnucash_db_file": "/home/user/.gnucash.sql.gnucash"
}
List accounts:
$ gt account list
List accounts and output in JSON:
$ gt account list --output json
List accounts that have Groceries in their name and output their short name (i.e “Groceries” instead of “Expenses:Groceries”):
$ gt account list --name-like "Groceries" --short-name
Get an account by guid:
$ gt account get 9b1d2bc513da4076b236aee6114b21a7
Get an account by account tree:
$ gt account get expenses:groceries
List transactions:
$ gt transaction list
List transactions and output in JSON:
$ gt transaction list --output json
List transactions for account guid:
$ gt transaction list --account 9b1d2bc513da4076b236aee6114b21a7
List up to 50 (limit defaults to 50) transactions for account tree:
$ gt transaction list --account expenses:groceries
List all transactions for account tree by setting limit to 0:
$ gt transaction list --account expenses:groceries --limit=0
List transactions for account tree and exclude totals:
$ gt transaction list --account expenses:petrol --include-totals=false
List transactions within a date range and with a description that contains %Pizza:
$ gt transaction list --start-post-date 2024-01-01 \
--end-post-date 2024-12-31 \
--description-like "%Pizza"
Update a transaction account:
$ gt transaction update 0000000000000000fa1ce5381fec0d51 \
--source-account expenses:pizza
--destination-account expenses:dining
Update many transactions account based on their description:
$ gt transaction bulk-update \
--description-like "%Pizza" \
--source-account expenses:pizza \
--destination-account expenses:dining
Update an account:
$ gt account update "expenses:automotive registration" \
--name "registration" \
--description "auto registration" \
--parent-account "expenses:automotive"
Generate an income and expense report:
$ gt report income-expense \
--start-date 2026-01-01 \
--end-date 2026-01-31