Skip to content

Switching Databases

Paul Ruane edited this page Apr 11, 2017 · 5 revisions

There are several ways to specify the database for TMSU to use:

  1. Local database file (/some/path/.tmsu/db)
  2. Environment variable (TMSU_DB)
  3. Command-line option (--database)
  4. Default database file ($HOME/.tmsu/default.db)

The recommended way is to initialise a local database.

Local Database

TMSU will look for a database named .tmsu/db under the current working directory or any parent directory of the current working directory. For example, if the current working directory is /home/on/the/range then TMSU will look for a database file at the following paths, using the first it finds:

/home/on/the/range/.tmsu/db
/home/on/the/.tmsu/db
/home/on/.tmsu/db
/home/.tmsu/db
/.tmsu/db

This allows you to have a TMSU database for a particular set of files. To set up such a database, use the init subcommand, which will create a new database under the current working directory:

$ cd /some/path
$ tmsu init
Creating new database at '/some/path/.tmsu/db'.

Environment Variable

TMSU will look for an environment variable called TMSU_DB. This will override use of the default and local databases.

$ export TMSU_DB=~/mydb
$ tmsu tags --all
fish
chips

If the file does not exist then it will be created automatically.

Command-Line Option

The database to use can be specified as a command-line option:

$ tmsu --database=~/mydb tags --all
fish
chips

Use of the command-line option has the highest precedence and overrides all of the other options. If this database file does not exist when TMSU is run then it will be created automatically.

To save specifying it each time, you can alias tmsu:

$ alias tmsu='tmsu --database=~/mydb'
$ tmsu tags --all
fish
chips

Default Database

Earlier versions of TMSU would create a database automatically if none could be found. TMSU no longer creates such a database, but for backwards compatibility it will still pick up a database at $HOME/.tmsu/default.db if no other can be found.

Clone this wiki locally