Chapter 10. Managing databases with the command-line assistant daemon


To store information and provide access to your history database, the command-line assistant daemon (clad) uses an unencrypted SQLite database by default. You can install and connect to a different database back end, such as PostgreSQL or MySQL.

Note

clad does not include these databases by default to avoid adding unwanted dependencies.

You can store and access your command-line assistant history by using the default unencrypted SQLite database.

Prerequisites

  • You have installed the command-line assistant.

Procedure

  1. Install the database of your choice:

    • To install MySQL, enter:

      # dnf install python3-PyMySQL
    • To install PostgreSQL, enter:

      # dnf install python3-psycopg2
  2. Access your database configuration file at /etc/xdg/command-line-assistant/config.toml.
  3. Locate and comment out the default configuration. For example:

     [database]
        # type = "sqlite"
        # connection_string = "/var/lib/command-line-assistant/history.db"
  4. Configure the database of your choice. The following information is also available in /etc/xdg/command-line-assistant/config.toml.

    1. Set the database type, where <db_type> can be mysql or postgresql.
    2. Set the database details.

       type = <db_type>
       host = "<hostname_or_ip_address>"
       port = "5432"
       username = "<database_user_name>"
       password = "<password>"
       database = "<database_name>"
  5. After changing the database type, restart the clad daemon to apply the changes:

    $ sudo systemctl restart clad

Use the systemd-creds tool to securely store your encrypted credentials. Connect to PostgreSQL, SQLite, or MySQL by using these stored secrets.

Prerequisites

  • The command-line assistant.
  • Access to the database configuration file.

Procedure

  1. Access your database configuration file at /etc/xdg/command-line-assistant/config.toml.
  2. Remove the username and password parameters from the [database] section, for example:

    [database]
    type = "postgresql"
    host = "localhost"
    port = "5432"
    database = "history"
    Note

    If you leave the username and password in the configuration file, these credentials take precedence over the systemd-creds tool.

  3. Generate encrypted credentials for your username or password. The following example uses systemd-ask-password commands. The name must follow the schema of database-username and database-password, otherwise, clad does not load the credentials properly.

    1. To generate an encrypted username, run the following command:

      $ systemd-ask-password -n | ( echo "[Service]" && systemd-creds encrypt --name=<database_username> -p - - ) >/etc/systemd/system/clad.service.d/<username>.conf
    2. To generate an encrypted password, run the following command:

      $ systemd-ask-password -n | ( echo "[Service]" && systemd-creds encrypt --name=<database_password> -p - - ) >/etc/systemd/system/clad.service.d/<password>.conf
  4. After updating the database credentials, reload systemd and restart the clad daemon to apply the changes:

    $ sudo systemctl daemon-reload
    $ sudo systemctl restart clad
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2026 Red Hat
Back to top