I had the sqlite3 package installed on Ubuntu and there's no support for readline. That means there's no command history and those other nifty features readline gives you.

Is this a configuration or a packaging problem? Is there a different package archive somewhere that would give me readline support out of the box? Or else, how do I compile sqlite3 myself making sure it has readline support?


You could always use rlwrap:

rlwrap sqlite3 database.db

FYI, I just checked my hardy heron install, and its sqlite3 does have readline support.

  • Didn't know about rlwrap. Really great, thanks! I'm using the sqlite3 package in Kubuntu Jaunty Jackalope and, for some reason, it didn't come with readline support. – Helder S Ribeiro Dec 14 '09 at 13:20

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.

  • 6
    Anaconda does the same thing. Argh! /usr/bin/sqlite3 works fine. – zbyszek Jun 26 '15 at 17:36
  • 2
    Thanks for pointing that out. My Android SDK was hiding my /usr/bin/sqlite3 application. – Dwayne Crooks Apr 1 '16 at 10:12
  • 1
    This was the case on my macOS High Sierra as well. You can check by running which sqlite3. – Shane Creighton-Young Mar 9 '18 at 15:09
  • 1
    +1, it was my issue as well, I had $ANDROID_HOME/Sdk/platform-tools after $PATH, but I just didn't install sqlite3. And I found this thread using exactly the same search phrase. – Meehow Jan 27 at 21:55
  1. Download the zip file containing C source code from https://www.sqlite.org/download.html (sqlite-amalgamation-nnnnnnn.zip)
  2. Unzip it to get shell.c, sqlite3.c, and the .h files.
  3. If not already installed, install libreadline and libncurses. On Ubuntu Linux, install by running the command below:

    sudo apt install libreadline-dev libncurses-dev

  4. 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.

  • This is the best answer. Note on Ubuntu 18.04 I first needed to run this: sudo apt install libreadline-dev libncurses-dev – rayzinnz Oct 12 '18 at 8:00
  • Thanks, I added the sudo apt install steps for completeness purposes. – Rob de la Cruz Oct 19 '18 at 17:33

I managed to compile my own binary with this:

Download the "autoconf" source file from SQLite Download page. Unzip and extract the tar, change to source directory.

Compile the source code with:

./configure --enable-readline

I am running on RedHat, so I had to run yum install readline-devel beforehand. This might be different on your machine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.