rainfrog Documentation

A database tool for the terminal

5,043 stars Rust Rust 1 file ยท ~6,763 tokens #database-management#mysql#postgresql#ratatui#rust#sql#sqlite#terminal
RAW Doc

Docker & Self-Hosted Deployment Verified OCI

Deploy rainfrog on any server, homelab, or cloud container platform.

1-Click Terminal Command
bash (docker run)
docker run -d --name rainfrog --restart always postgres:16.3
Configured Services & Ports
โš™๏ธ rainfrog-postgres
image: postgres:16.3
๐Ÿ”Œ Ports: ${PG_PORT}:5432
โš™๏ธ rainfrog-mysql
image: mysql:8.4
๐Ÿ”Œ Ports: ${MYSQL_PORT}:3306
โš™๏ธ rainfrog-oracle
image: gvenzl/oracle-free:23-slim
๐Ÿ”Œ Ports: ${ORACLE_PORT}:1521
docker-compose.yml
yaml (docker-compose.yml)
services:

  rainfrog-postgres:
    container_name: rainfrog-postgres
    image: postgres:16.3
    environment:
      POSTGRES_USER: "root"
      POSTGRES_PASSWORD: "password"
      POSTGRES_DB: "rainfrog"
    ports:
      - "${PG_PORT}:5432"
    volumes:
      - ./dev/pg_init.sql:/docker-entrypoint-initdb.d/00_init.sql

  rainfrog-mysql:
    container_name: rainfrog-mysql
    image: mysql:8.4
    environment:
      MYSQL_ROOT_PASSWORD: "password"
      MYSQL_DATABASE: "rainfrog"
    ports:
      - "${MYSQL_PORT}:3306"
    volumes:
      - ./dev/mysql_init.sql:/docker-entrypoint-initdb.d/schema.sql

  rainfrog-oracle:
    container_name: rainfrog-oracle
    image: gvenzl/oracle-free:23-slim
    environment:
      ORACLE_PASSWORD: password
      APP_USER: rainfrog
      APP_USER_PASSWORD: password
      ORACLE_DATABASE: rainfrog
    ports:
      - "${ORACLE_PORT}:1521"
    volumes:
      - ./dev/oracle_init.sql:/container-entrypoint-initdb.d/init.sql

๐Ÿธ rainfrog

a database tool for the terminal

features

the goal for rainfrog is to provide a lightweight, terminal-based tool for
interacting with databases.

  • efficient navigation via vim-like keybindings and mouse controls
  • query editor with keyword highlighting, session history, and favorites
  • quickly copy data, filter tables, and switch between schemas
  • shortcuts to view table metadata and properties
  • cross-platform (macOS, linux, windows, android via termux)

why "rainfrog"?

frogs find refuge in elephant tracks

supported databases

the levels of support for different databases can be split into 4 tiers:

  • tier 1: most frequently tested, bugs will be addressed as soon as possible.
  • tier 2: often tested, fixed when necessary.
  • tier 3: community supported; contributions are welcome, but otherwise development is minimal.
  • tier 4: new or experimental; should be treated as unstable, and behavior is subject to change.
database tier known issues via wire protocol*
postgres 1
mysql 2
sqlite 2
redshift 2 postgres
duckdb 3 prebuilt duckdb and musl binaries do not include this driver
oracle 4 requires additional runtime dependencies

*the postgres driver can also be used to connect to other databases that support
the postgres wire protocol, such as AWS Redshift. however, this functionality is not
well tested. in theory, the mysql driver should be able to do the same for databases
that support the mysql protocol. check each database's documentation for compatibility.

disclaimer

this software is currently under active development; expect breaking changes,
and use at your own risk. it is not recommended to use this tool with write
access on a production database.

table of contents

installation

cargo

after installing rust (recommended to do so via
rustup):

sh
cargo install rainfrog --locked

by default, all features are included. some features may not be compatible with your platform;
check Cargo.toml to see what feature combinations are available.

if you have cargo-binstall, you can run:

sh
cargo binstall rainfrog

homebrew

sh
brew install rainfrog

arch linux

arch linux users can install from the
official repositories
using pacman:

sh
pacman -S rainfrog

termux

if you are using termux, you'll need to install rust via
their package manager:

sh
pkg install rust

and then make sure to install with termux features (and disable default
features):

sh
cargo install rainfrog --no-default-features

nix

sh
nix-env -iA nixos.rainfrog

conda

sh
conda install -c conda-forge rainfrog

pixi

The command below installs rainfrog from conda-forge, the same repository as conda, but unlike conda it can be installed user-globally using pixi.

sh
pixi global install rainfrog

install script

there is a simple install script that assists in downloading and unpacking a
binary from the release page to ~/.local/bin/, which you might want to add to
your PATH variable if it isn't already there. you'll need to select which
binary is appropriate for your system (if you're not sure, you can find out by
installing rust and running rustc -vV to see the "host" target), and the
script also needs jq and
fzf installed to run.

sh
curl -LSsf https://raw.githubusercontent.com/achristmascarl/rainfrog/main/install.sh | bash

release page binaries

  1. manually download and unpack the appropriate binary for your os from the
    latest release (if
    you're not sure which binary to pick, you can find out by installing rust and
    running rustc -vV to see the "host" target)
  2. move the binary to a folder in your PATH environment variable

icons

you will need to have a nerd font installed and used by your terminal for the icons to show up.

dependencies

for some of the databases supported by rainfrog, the driver has additional runtime dependencies.
you can find instructions for installing those dependencies below.

oracle

the oracle driver uses ODPI-C, which requires Oracle Client libraries to be installed. instructions
for installing the Oracle Instant Client can be found here: ODPI-C Installation.

after installation, you may need to manually copy the client files to a
location where ODPI-C can find them, which is either in the same folder as the rainfrog binary,
or in the library path of your os. more details can be found in the ODPI-C
installation instructions: ODPI-C Client Library Loading.

usage

sh
Usage: rainfrog [OPTIONS] [COMMAND]

Commands:
  edit  Edit the config file (create it first if missing)
  help  Print this message or the help of the given subcommand(s)

Options:
  -M, --mouse <MOUSE_MODE>       Whether to enable mouse event support. If enabled, your terminal's
                                 default mouse event handling will not work. [possible values: true,
                                 false]
  -u, --url                 Full connection URL for the database, e.g.
                                 postgres://username:password@localhost:5432/dbname
      --username       Username for database connection
      --password       Password for database connection
  -R, --reenter-password         Reenter the password for a saved database connection
      --host <HOST>              Host for database connection (ex. localhost)
      --port               Port for database connection (ex. 5432)
      --database <DATABASE>      Name of database for connection (ex. postgres)
      --driver <DRIVER>          Driver for database connection (ex. postgres)
      --enable-cleartext-plugin  Enable MySQL cleartext plugin
      --ssl-required             Require an SSL/TLS connection (supported by PostgreSQL, MySQL, and
                                 Oracle)
  -h, --help                     Print help
  -V, --version                  Print version

with connection options

if any options are not provided, you will be prompted to input them.
if you do not provide an input, that option will
default to what is in your environment variables.

sh
rainfrog \
  --driver <db_driver> \
  --username  \
  --host <hostname> \
  --port <db_port> \
  --database <db_name> \
  --ssl-required

with connection url

the connection_url must include all the necessary options for connecting
to the database (ex. postgres://username:password@localhost:5432/postgres).
it will take precedence over all connection options.

sh
rainfrog --url $(connection_url) --ssl-required

--ssl-required overrides the transport setting from a connection URL. It selects
PostgreSQL's require mode, MySQL's required mode, or Oracle's tcps protocol.
SQLite and DuckDB do not support SSL/TLS connections. Advanced certificate and
verification settings can still be supplied in PostgreSQL and MySQL URL parameters,
or through an Oracle Easy Connect string and Oracle client configuration.

with environment variables

if connection_url is not present, rainfrog will first check your DATABASE_URL
environment variable, then it will check for DATABASE_URL in a .env file in
the current directory or a parent directory.

`docker run`

for postgres and mysql, you can run it by specifying all
of the options as environment variables:

sh
docker run --platform linux/amd64 -it --rm --name rainfrog \
  --add-host host.docker.internal:host-gateway \
  -e db_driver="db_driver" \
  -e username="" \
  -e password="" \
  -e hostname="host.docker.internal" \
  -e db_port="<db_port>" \
  -e db_name="<db_name>" achristmascarl/rainfrog:latest

if you want to provide a custom combination of
options and omit others, you can override the Dockerfile's
CMD like so:

sh
docker run --platform linux/amd64 -it --rm --name rainfrog \
  achristmascarl/rainfrog:latest \
  rainfrog # overrides CMD, additional options would come after

since sqlite is file-based, you may need to mount a path to
the sqlite db as a volume in order to access it:

sh
docker run --platform linux/amd64 -it --rm --name rainfrog \
  -v ~/code/rainfrog/dev/rainfrog.sqlite3:/rainfrog.sqlite3 \
  achristmascarl/rainfrog:latest \
  rainfrog --url sqlite:///rainfrog.sqlite3

running drivers which have runtime dependencies (like oracle) via docker
is not currently supported.

customization

rainfrog can be customized by placing a rainfrog_config.toml file in
one of the following locations depending on your os, as determined by
the directories crate:

Platform Value Example
Linux $XDG_CONFIG_HOME/_project_path_ or $HOME/.config/_project_path_ /home/alice/.config/barapp
macOS $HOME/Library/Application Support/_project_path_ /Users/Alice/Library/Application Support/com.Foo-Corp.Bar-App
Windows {FOLDERID_LocalAppData}\_project_path_\config C:\Users\Alice\AppData\Local\Foo Corp\Bar App\config

you can change the default config directory by exporting an environment variable.
to make the change permanent, add it to your .zshrc/.bashrc/.*rc file:

sh
export RAINFROG_CONFIG=~/.config/rainfrog

[!WARNING]
this should be the path to the directory that the config file is in,
NOT the path to the actual file

settings

Name Default Description
mouse_mode true whether to capture mouse events. capturing mouse events allows you to change focus and scroll using the mouse. however, your terminal will not handle mouse events like it normally does (you won't be able to copy by highlighting, for example).
data_compact_columns true whether column widths should be dynamic based on the length of the contents of each column. there is still a max column width that won't be exceeded, so this will save some space by compressing the widths of columns with shorter strings.
data_row_spacer false whether rows will have a space separating them to make the data table less visually dense.
autocomplete_enabled true whether completions are requested while editing SQL.
autocomplete_debounce_ms 100 how long edit-triggered completion waits before refreshing or hiding the menu.
autocomplete_trigger_len 1 minimum identifier length for automatic completion; Ctrl+Space bypasses it.
autopairs_enabled true whether insert mode automatically closes single quotes, double quotes, brackets, braces, parentheses, and backticks at the end of a line or before whitespace; skips an adjacent closing half; and removes both halves when backspacing an empty pair.

database connections

database connections can be configured in the configuration file as shown below:

text
[db]
postgres-local = { host = "localhost", driver = "postgres", port = 5432, database = "postgres", username = "postgres",  default = true }
postgres-dev = { connection_string = "postgresql://postgres:[email protected]:5432", driver = "postgres" }
mysql-local = { host = "localhost", driver = "mysql", port = 32768, database = "rainfrog", username = "root" }
sqlite-memory = { connection_string = "sqlite://:memory:", driver = "sqlite"}
sqlite-disk = { connection_string = "sqlite://./my_database.db", driver = "sqlite"}
oracle-local = { host = "localhost", driver = "oracle", port = 1521, database = "rainfrog", username = "rainfrog" }

the connection details can be provided in two formats: a raw connection string or specifying individual fields.
connections input are prioritized in the following order:

  • cli input
  • DATABASE_URL env variable
  • config file

if no database connection in the config is set as the default connection,
a prompt will appear to select the desired database. The user will also be
prompted for the password for the selected database and will have the option to
store it in a platform specific keychain for future reuse.
Pass --reenter-password (or -R) to revoke a saved keychain password before
being prompted to enter and optionally save its replacement.

future plans for database connections include switching database without having to restart rainfrog.

keybindings

you can customize some of the default keybindings, but not all of
them. to see a list of the ones you can customize, see the default
config file at .config/rainfrog_config.toml. below
are the default keybindings.

n.b. for mac users

on mac, for VS Code, terminal, kitty, and others, a setting for
"use option as meta key" needs to be turned
on for Alt/Opt keybindings to work. (In VS Code, it's
"terminal.integrated.macOptionIsMeta": true in the settings; in
kitty, it's macos_option_as_alt yes in the config.)

general

keybinding description
Ctrl+c quit program
Alt+1, Ctrl+k change focus to menu
Alt+2, Ctrl+j change focus to query editor
Alt+3, Ctrl+h change focus to results
Alt+4, Ctrl+g change focus to query history
Alt+5, Ctrl+m change focus to query favorites
Tab cycle focus forwards
Shift+Tab cycle focus backwards
q, Alt+q in query editor abort current query

keybinding description
j, โ†“ move selection down by 1
k, โ†‘ move selection up by 1
g jump to top of current list
G jump to bottom of current list
h, โ† focus on schemas (if more than 1)
l, โ†’ focus on tables
/ filter tables
Esc clear filter
Backspace focus on tables
Enter when searching focus on tables
Enter with selected schema focus on tables
Enter with selected table preview table (100 rows)
R reload schemas and tables

query editor

keybindings may not behave exactly like vim. the full list of active
Vim keybindings in rainfrog can be found at vim.rs.

Keybinding Description
Alt+Enter, F5 Execute query
Alt+e, F6 Edit query in external editor
F7 Bypass parser to execute query (cannot rollback, no validation)
Ctrl+Space Show SQL, schema, buffer, or path completions
Tab, Enter Accept the selected completion
Up, Down, Ctrl+p, Ctrl+n Navigate completions
Esc Dismiss completions; press again for normal mode
j, โ†“ Move cursor down 1 line
k, โ†‘ Move cursor up 1 line
h, โ† Move cursor left 1 char
l, โ†’ Move cursor right 1 char
w Move cursor to next start of word
e Move cursor to next end of word
b Move cursor to previous start of word
0 Move cursor to beginning of line
$ Move cursor to end of line
gg Jump to top of editor
G Jump to bottom of current list
Esc Return to normal mode
i Enter insert (edit) mode
I Enter insert mode at beginning of line
A Enter insert mode at end of line
o Insert new line below and enter insert
v Enter visual (select) mode
V Enter visual mode and select line
r Begin replace operation
y Begin yank (copy) operation
x Begin cut operation
p Paste from clipboard
u Undo
Ctrl+r Redo
Ctrl+e Scroll down
Ctrl+y Scroll up
Ctrl+f*, Alt+f Save query to favorites

*only works in normal mode

query history

keybinding description
j, โ†“ move selection down by 1
k, โ†‘ move selection up by 1
g jump to top of list
G jump to bottom of list
y copy selected query
I edit selected query in editor
D delete all history

query favorites

keybinding description
j, โ†“ move selection down by 1
k, โ†‘ move selection up by 1
g jump to top of list
G jump to bottom of list
y copy selected query
I edit selected query in editor
D delete selected query
/ filter favorites
Esc clear filter

results

keybinding description
P export results to csv
j, โ†“ scroll down by 1 row
k, โ†‘ scroll up by 1 row
h, โ† scroll left by 1 cell
l, โ†’ scroll right by 1 cell
b scroll right by 1 cell
e, w scroll left by 1 column
{, PageUp, Ctrl+b jump up one page
}, PageDown, Ctrl+f jump down one page
g jump to top of table
G jump to bottom of table
0 jump to first column
$ jump to last column
v select individual field
V select row
Enter change selection mode inwards
Backspace change selection mode outwards
y copy selection
Esc stop selecting

exports

query results can be exported to csv. exporting is a blocking action,
so be careful about exporting too many rows at once, as it will freeze
the application.

the file will be saved in your downloads directory, which is one of the
following depending on your os, as determined by
the directories crate:

Platform Value Example
Linux XDG_DOWNLOAD_DIR /home/alice/Downloads
macOS $HOME/Downloads /Users/Alice/Downloads
Windows {FOLDERID_Downloads} C:\Users\Alice\Downloads

you can change the default export location by exporting an environment variable.
to make the change permanent, add it to your .zshrc/.bashrc/.*rc file:

sh
export RAINFROG_EXPORT=~/Documents

favorites

frequently used queries can be saved as favorites. by default,
favorites are written to the application's data directory (the
same place that logs are written to), which is one of the
following depending on your os, as determined by
the directories crate:

Platform Value Example
Linux $XDG_DATA_HOME/_project_path_ or $HOME/.local/share/_project_path_ /home/alice/.local/share/barapp
macOS $HOME/Library/Application Support/_project_path_ /Users/Alice/Library/Application Support/com.Foo-Corp.Bar-App
Windows {FOLDERID_LocalAppData}\_project_path_\data C:\Users\Alice\AppData\Local\Foo Corp\Bar App\data

each favorite will be a separate .sql file.
you can change the default export location by exporting an environment variable.
to make the change permanent, add it to your .zshrc/.bashrc/.*rc file:

sh
export RAINFROG_FAVORITES=~/.config/rainfrog/favorites

known issues and limitations

  • geometry types are not currently supported
  • for x11 and wayland, yanking does not copy to the system clipboard, only
    to the query editor's buffer. see https://github.com/achristmascarl/rainfrog/issues/83
  • in visual mode, when selecting an entire line, the behavior is not the same as
    vim's, as it simply starts the selection at the head of the line, so
    moving up or down in lines will break the selection.
  • mouse events are only used for changing focus and scrolling; the editor does
    not currently support mouse events, and menu items cannot be selected using
    the mouse

you can find other reported issues in the
issues tab

Contributing

for bug reports and feature requests, please create an issue.

please read CONTRIBUTING.md before opening issues
or creating PRs.

acknowledgements