Listing Sports with sports

kent sports lists the distinct sport and sub-sport combinations a database contains, one row each, sorted by name.

It is read-only, and it reports what this database actually holds rather than every sport the schema can represent. The schema can describe dozens; a database usually contains one or two.

Synopsis

kent sports <dbfilename>

What it shows

$ kent sports mydata.sqlite
Database:  mydata.sqlite

Sport    Sub-sport
Running  Generic

A database of a different sport reports that sport, and the sub-sport is often the more informative half:

$ kent sports swim.sqlite
Database:  swim.sqlite

Sport     Sub-sport
Swimming  Lap Swimming

Combinations, not two separate lists. A database holding both open-water and pool swimming lists Swimming twice, once per sub-sport, because the pair is what distinguishes them.

What it is for

It answers one question quickly: what is in this database? That is worth its own command because activities prints every session, and a database of 300 runs takes 300 rows to tell you it holds running.

It is also the honest way to check a database before writing a report against it. A script that assumes one sport can test this first.

A database with no sports

A database created but never imported into prints a plain statement and succeeds:

$ kent createdb mydata.sqlite
$ kent sports mydata.sqlite
Database:  mydata.sqlite

No sports recorded.
$ echo $?
0

A path that does not exist is reported as missing and is not created:

$ kent sports nope.sqlite
kent sports: nope.sqlite does not exist
$ echo $?
1

An older database is refused

Like the other reading commands, this one reads specific named columns, so a database older than this build expects is refused with an explanation:

$ kent sports old.sqlite
kent sports: this database reports schema version 1, older than the version 2 this build of cordelia expects. Use `kent sqldump` to export it instead
$ echo $?
1

What it is not

sports counts nothing. It does not say how many activities each sport has, or when they happened. For that, see kent activities, which lists every session with its dates and its sport.

See also