SQLite is the most widely deployed relational database engine in computing, powering embedded mobile applications, browser local storage, desktop software, and developer testing environments. However, the standard native sqlite3 command-line shell lacks modern developer amenities such as intelligent autocompletion, context-aware syntax highlighting, and multi-line editing. In Linux, litecli solves these limitations by delivering a user-friendly, feature-packed interactive CLI for SQLite databases.
Key Capabilities of litecli
Built using the Python Prompt Toolkit and following the successful lineage of pgcli (for PostgreSQL) and mycli (for MySQL), litecli provides an enriched shell experience that significantly accelerates database exploration and SQL scripting:
- Intelligent Auto-Completion: As you type SQL queries, litecli dynamically suggests SQL keywords, table names, view identifiers, and column attributes based on the active database schema.
- Syntax Highlighting: SQL commands, strings, operators, and comments are color-coded in real time, making queries easier to read and debug before execution.
- Adaptive Table Formatting: Tabular query results automatically adjust to terminal dimensions, with multiple border styles (such as ascii, psql, fancy_grid, and plain).
- Integrated Paging: Query results that exceed the terminal viewport automatically pipe into an interactive pager (such as
less), preventing screen flooding. - Configuration Profiles: Custom keybindings (including Vi mode), custom color schemes, and favorite saved queries are easily managed via a user-level configuration file.
Installing litecli on Linux Distributions
Because litecli is developed in Python, it can be installed across all Linux distributions using pipx (recommended for isolated CLI tools) or standard distribution package managers.
Method 1: Installing via pipx (Recommended)
Using pipx installs litecli into an isolated virtual environment while making its executable globally accessible without polluting system Python libraries:
# Install pipx if not already present
sudo apt update && sudo apt install -y pipx
pipx ensurepath
# Install litecli
pipx install litecli
Method 2: Installing via Native Package Managers
On Arch Linux and Manjaro, litecli is available directly from the community repositories:
sudo pacman -S litecli
For Debian and Ubuntu systems using Python 3 virtual environments:
sudo apt install python3-pip
pip install litecli --user
Verify that litecli is installed and verify its version number by running:
litecli --version
Connecting to and Querying SQLite Databases
Launching litecli is identical to using the standard sqlite3 binary. Simply pass the path to your database file as an argument:
litecli production.db
If the specified file does not exist, SQLite automatically creates a new empty database upon your first write operation.
Executing Interactive Queries
Once inside the litecli prompt, begin typing SQL statements. As soon as you type SELECT * FROM , an interactive pop-up menu displays all available tables. Use the arrow keys or Tab to cycle through suggestions, and press Enter to autocomplete.
production.db> SELECT id, username, email, created_at
FROM users
WHERE is_active = 1
ORDER BY created_at DESC
LIMIT 5;
Useful Special and Dot Commands
In addition to standard ANSI SQL syntax, litecli supports specialized meta-commands that simplify schema inspection:
| Command | Operational Purpose |
|---|---|
\dt or .tables |
Lists all tables in the current database |
\d <table_name> or .schema <table_name> |
Displays the full DDL schema and column types for a designated table |
\T <format> |
Changes output table format (e.g. \T fancy_grid, \T psql, \T csv) |
\e |
Opens your default system text editor (such as Nano or Vim) to edit long queries |
\q or .exit |
Exits the litecli interactive shell |
Managing Saved and Named Queries
When conducting repetitive database maintenance or auditing tasks, litecli allows you to save frequently used queries with custom aliases:
1. Saving a Named Query
production.db> \ns active_subscribers SELECT id, email, plan FROM users WHERE status = 'active';
2. Executing a Saved Query
To run the saved query later, simply use the \n command followed by the alias:
production.db> \n active_subscribers
3. Listing All Saved Queries
production.db> \n
Customising the litecli Configuration File
litecli generates a configuration file located at ~/.config/litecli/config upon first launch. Open it in a text editor to personalise your workspace:
nano ~/.config/litecli/config
Key configuration directives include:
key_bindings = vi: Enables Vi-style modal editing commands for terminal power users.table_format = fancy_grid: Sets bordered unicode grids as the default output display.syntax_style = monokai: Changes the active syntax color theme.destructive_warning = True: Prompts for confirmation before executing potentially destructive SQL statements such asDROP TABLEorTRUNCATE.