SQLite with readline support on Ubuntu
You could always use rlwrap:
rlwrap sqlite3 database.db
FYI, I just checked my hardy heron install, and its sqlite3 does have readline support.
I add another answer because this is the first hit for "ubuntu sqlite3 readline" on google:
The android SDK installs its own version of the sqlite3
binary. This binary does not provide readline
support. If you added the Android SDK to your path this might make you think you have no readline
support, in fact every Ubuntu package is compiled with readline
support.
Also see this Ubuntu Bug Report which describes the same situation.
- Download the zip file containing C source code from https://www.sqlite.org/download.html (sqlite-amalgamation-nnnnnnn.zip)
- Unzip it to get shell.c, sqlite3.c, and the .h files.
If not already installed, install libreadline and libncurses. On Ubuntu Linux, install by running the command below:
sudo apt install libreadline-dev libncurses-dev
Run the command below to build:
gcc -DSQLITE_ENABLE_FTS5 -DHAVE_READLINE shell.c sqlite3.c -lpthread -ldl -lm -lreadline -lncurses -o sqlite3
Note: You need -DHAVE_READLINE and -lreadline and -lncurses to get readline functionality.
Copy the sqlite3 binary to /usr/bin or add to your path.