LinuxCommandLibrary

litecli

Connect and query SQLite databases

SYNOPSIS

litecli [OPTIONS] [DATABASE_FILE]

Connects to a specified SQLite database file. If no file is provided, it connects to an in-memory database.

PARAMETERS

-h, --help
    Displays the help message and exits.

-v, --version
    Shows the program's version number and exits.

-e TEXT, --execute TEXT
    Executes the specified SQL query and then exits the application.

-q, --quiet
    Suppresses the initial welcome message when starting litecli.

--rc-file TEXT
    Specifies an alternative path to the litecli configuration file.

--output TEXT
    Redirects all program output (including query results) to the specified file.

--csv
    Outputs query results in Comma Separated Values (CSV) format.

--json
    Outputs query results in JSON (JavaScript Object Notation) format.

--tsv
    Outputs query results in Tab Separated Values (TSV) format.

--pretty
    Enables pretty-printed (formatted) table output for results.

--vertical
    Displays query results in a vertical mode, with each column on a new line.

--pager TEXT
    Uses the specified command (e.g., less) as a pager for large query outputs.

DATABASE_FILE
    The path to the SQLite database file to connect to. If omitted, litecli connects to a temporary, in-memory database.

DESCRIPTION

litecli is a modern and user-friendly command-line interface for SQLite databases. Built on the foundations of popular tools like mycli and pgcli, it significantly enhances the standard SQLite command-line experience. Key features include intelligent autocompletion, which suggests tables, columns, and SQL keywords as you type, and syntax highlighting for improved readability of queries. It also offers pretty table formatting for query results, making output easier to digest, especially for complex data.

litecli supports multiline queries, customizable output formats (like CSV, JSON, TSV, or vertical mode), and seamless integration with external pagers (e.g., less) and editors. It's an excellent alternative to the default sqlite3 CLI, providing a more productive and visually appealing environment for interacting with SQLite databases.

CAVEATS

litecli requires Python 3 and its associated dependencies to be installed. While it aims for high compatibility, some advanced or obscure SQLite shell dot-commands (.commands) might behave differently or not be fully supported compared to the native sqlite3 command-line utility. For very large result sets, the --pager option or redirecting output to a file is recommended to prevent overwhelming the terminal. Configuration changes made through the CLI options are temporary and do not persist unless saved to the configuration file (e.g., ~/.config/litecli/config).

<B>CONFIGURATION</B>

litecli can be extensively configured via a configuration file, typically located at ~/.config/litecli/config. This file allows users to customize various aspects, including keybindings, colors, output formats, and behavior of autocompletion. The --rc-file option allows specifying an alternative configuration file for specific sessions or projects.

<B>INTERACTIVE FEATURES</B>

Beyond basic autocompletion, litecli offers smart completion (context-aware suggestions), multiline input mode (enabled by default or with --expansion), and a robust history search. These features significantly boost productivity for frequent SQLite users by reducing typing and errors.

HISTORY

litecli emerged as part of a family of modern command-line database clients, primarily influenced by the success and design principles of mycli (for MySQL) and pgcli (for PostgreSQL). Developed by Amjith Ramanujam and other contributors, it brought the enhanced features of autocompletion, syntax highlighting, and intelligent formatting to the SQLite ecosystem. Its development focused on providing a more intuitive and productive experience for SQLite users, leveraging Python's extensibility to build a rich interactive shell on top of the sqlite3 library.

SEE ALSO

sqlite3(1): The official SQLite command-line shell., mycli(1): A similar command-line client for MySQL., pgcli(1): A similar command-line client for PostgreSQL., psql(1): The official PostgreSQL interactive terminal., mysql(1): The official MySQL command-line client.

Copied to clipboard