| Crates.io | rsqlite3 |
| lib.rs | rsqlite3 |
| version | 1.0.0 |
| created_at | 2026-01-25 18:41:19.762596+00 |
| updated_at | 2026-01-25 18:41:19.762596+00 |
| description | A drop-in replacement for sqlite3 CLI with enhanced features |
| homepage | |
| repository | https://github.com/xuwaters/rsqlite3.git |
| max_upload_size | |
| id | 2069297 |
| size | 263,035 |
A drop-in replacement for the sqlite3 CLI written in Rust with enhanced features.
Essential Commands:
.quit / .exit - Exit the program.help - Show help message.tables [PATTERN] - List tables (optionally filtered).schema [TABLE] - Show CREATE statements.mode [MODE] - Set output mode.headers on|off - Toggle column headers.show - Show current settingsFile Operations:
.dump [TABLE] - Generate SQL dump.import FILE TABLE - Import CSV into table.output [FILE] - Redirect output to file.read FILE - Execute SQL from file.open FILE - Close existing database and reopen FILEDatabase Operations:
.databases - List attached databases.separator SEP - Set column separator.nullvalue STRING - Set NULL display value.width NUM1 NUM2 ... - Set column widths for "column" modeOther:
.timer on|off - Show query execution time.echo on|off - Echo commands before executing.bail on|off - Stop after hitting an errorgit clone <repository-url>
cd rsqlite3
cargo build --release
The binary will be at target/release/rsqlite3.
Install to your PATH:
cargo install --path .
Start the REPL:
rsqlite3 database.db
rsqlite3 version 1.0.0
Enter ".help" for usage hints.
Connected to database.db
rsqlite3> CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);
rsqlite3> INSERT INTO users VALUES (1, 'Alice');
rsqlite3> SELECT * FROM users;
1|Alice
rsqlite3> .mode column
rsqlite3> .headers on
rsqlite3> SELECT * FROM users;
id name
-- -----
1 Alice
rsqlite3> .quit
Execute SQL directly from command line:
rsqlite3 database.db "SELECT * FROM users"
Process SQL from files or pipes:
echo "SELECT * FROM users;" | rsqlite3 database.db
# Or from a file
rsqlite3 database.db < script.sql
Usage: rsqlite3 [OPTIONS] [DATABASE] [SQL]
Arguments:
[DATABASE] Path to the SQLite database file
[SQL] SQL command to execute
Options:
-H, --header Show column headers
--noheader Do not show column headers
-m, --mode <MODE> Set output mode (list, csv, column, json, jsonl, line, table, markdown)
-s, --separator <SEP> Set column separator for list mode
-n, --nullvalue <TEXT> Set NULL value display string
-r, --readonly Open database in read-only mode
--init <FILE> Execute SQL from init file before processing
--cmd <COMMAND> Run command before reading stdin
-e, --echo Echo commands before executing
-b, --bail Stop after hitting an error
--color Enable color output
--no-color Disable color output
-h, --help Print help
-V, --version Print version
Column mode with headers:
rsqlite3 data.db "SELECT * FROM users" --mode column --header
JSON output:
rsqlite3 data.db "SELECT * FROM products" --mode json
JSON Lines output:
rsqlite3 data.db "SELECT * FROM products" --mode jsonl
Table mode (pretty printing with colors):
rsqlite3 data.db "SELECT * FROM orders" --mode table --header --color
Output:
┌────┬───────────┬────────┐
│ id │ product │ amount │
├────┼───────────┼────────┤
│ 1 │ Laptop │ 999.99 │
│ 2 │ Mouse │ 29.99 │
└────┴───────────┴────────┘
(2 rows)
CSV export to file:
rsqlite3 data.db "SELECT * FROM users" --mode csv > users.csv
Import CSV:
rsqlite3 data.db ".import users.csv users"
Dump database:
rsqlite3 data.db ".dump" > backup.sql
.schema <Tab> → suggests table names.mode <Tab> → suggests output modes.headers <Tab> → suggests on/offSELECT * FROM <Tab> -- Shows all tables
SELECT n<Tab> -- Completes column names
.<Tab> -- Shows all dot commands
.schema <Tab> -- Shows table names
.mode <Tab> -- Shows output modes (csv, json, table, etc.)
# Beautiful colored tables
rsqlite3 data.db "SELECT * FROM users" --mode table --header --color
For detailed information about these features, see FEATURES.md.
rsqlite3 aims to be a drop-in replacement for the standard sqlite3 CLI. Most common workflows should work identically.
--color flag)src/
├── main.rs - CLI entry point and argument parsing
├── repl.rs - REPL loop and interactive shell
├── cli_state.rs - Session state and configuration
├── db.rs - Database operations
├── sql_executor.rs - SQL execution with formatting
├── output.rs - Output formatting system
├── dot_commands.rs - Dot command handlers
├── import_export.rs - Import/export functionality
├── completion.rs - Tab completion logic
├── lsp.rs - Language server protocol features (internal)
└── sql_highlight.rs - Syntax highlighting
# Debug build
cargo build
# Release build (optimized)
cargo build --release
# Run tests
cargo test
# Run with logging
RUST_LOG=debug cargo run
MIT OR Apache-2.0
Contributions are welcome! Please feel free to submit issues or pull requests.
This project was built with the assistance of Claude Code and Gemini CLI.
Built with: