Training Database
Toolset for registrering weight training with a focus on ease of registrering from a command line.
To install, start by creating the database:
create database training;
create user 'jakob';
Create the table and view structure by executing db/createdb.sql and load initial data by db/load.sql -- you might want to
change the name from 'jakob' to something else (and do that consistenly throughout).
Edit pg_hba.conf to have 'jakob' access the training database directly:
# TYPE DATABASE USER ADDRESS METHOD
local training jakob peer
As postgres user, do a config reload:
select pg_reload_conf();
Then install rust toolchain by rustup.rs -- make and install the binary (I am assuming you have
a bin directly in your homedir, that is in your path):
cd train-cli
cargo build --release
cp target/release/train-cli $HOME/bin/train
Right now the executable is hardcoded with database name training and the use
of unix domain socket in /var/run/postgresql.
Now training can be invoked with:
train report squat 3 10 60
Which would register squauts, 3 runs of 10 reps of 60kg -- at local time and date. Optionally a time, date time or rfc3339 timestamp can be specified:
train report squat 3 10 60 "12:05:00"
train report squat 3 10 60 "2025-12-24 18:00:00"
train report squat 3 10 60 "2025-12-24T18:00:00+0200"
The two former will source missing date and timezone information from the user session, i.e.
type date on your commandline to see what you have.
When travelling you might opt for specifying a specific location on the command line, like:
TZ=Australia/Sydney train report squat 3 10 60
To insert messages into the graph, use the messsage command:
train message "Still F55.3"
The message command takes time as an optional 2nd arguments, just as the report command.
Grafana Visaulisation
In grafana/training-dashboard.json a small dashboard is presented, a Postgres data source
must be defined, and the data base user must have access to select from tables in the training database.
grant select on account to grafana_query;
grant select on training to grafan_query;
grant select on exercise to grafan_query;
grant select on dailylist to grafan_query;
grant select on message to grafana_query;