Sqlite is kinda frustrating. Each time I run a command, I\'m not able to use the up down left right arrows to retrieve my previously typed commands. Is there any way to enab
First problem: Your insert statement contains 2 fields but your table has 3 fields, so it's ambiguous. SQLite can't determine which fields you want to set. The second problem is: don't set your resourceID to null if you want to use the autoincrement.
Try this:
insert into resource(resourceType) values ("razor");
This will set the resourceID to the next value of the autoincrement and the userID to the default value.
I'm using Linux Mint and had the same sqlite3 issue, but solved it partly with the answers here. I was initially using the sqlite3 found in anaconda, which didn't have readline support.
After I renamed the sqlite3 file in anaconda, reinstalling using the autoconf as mentioned above still didn't fix the issue. The ldd command didn't show a link to readline.so:
$ ldd $(which sqlite3)
linux-vdso.so.1 => (0x00007ffebb3a4000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f8aceb9e000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f8ace980000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8ace5bb000)
/lib64/ld-linux-x86-64.so.2 (0x00007f8aceda2000)
Then,
$ sudo dpkg -r sqlite3
followed by a reinstall did the trick.
A quick solution is to launch SQLite with ReadLine support like following:
rlwrap sqlite3 database.db
If rlwrap
is not installed, you can do so on Ubuntu using the command:
sudo apt-get install rlwrap
For other Linux versions, check here.
rlwrap
is a ReadLine wrapper, a small utility that uses the GNU readline library to allow the editing of keyboard input for any other command.
Here are two answers for two questions:
I find that using the sqlite3 command line client my arrow keys work without trouble.
You have two errors in your INSERT statement:
You should not supply a value for the AUTOINCREMENT column.
You should list the columns and the order in which to map the values. This is required when you do not have the same amount of values as columns, but it's good practice even when you do, because later changes to the table's structure may change the order or number of columns.
Also, single quotes are more standard in SQL databases. SQLite will accept the double quotes, some other programs won't.
INSERT INTO Resource (ResourceType) VALUES ('razor')
I had the same problem on OS X.
In order to fix it, you need to compile the sqlite3 yourself. The precompiled binaries can't assume that you've got readline support, so they left that out.
If you download the "autoconf" source from http://www.sqlite.org/download.html (second link, currently to http://www.sqlite.org/sqlite-autoconf-3071300.tar.gz ):
then you can compile it via the terminal (cd to the directory the tarball extracts to):
$ ./configure
$ make
$ sudo make install
and it will automatically recognise that OS X has readline and curses support and your new sqlite3 binary will respond as expected to the arrows, delete key etc.
For the arrow keys to work within the sqlite3 command prompt, the sqlite3 binary needs to be linked to the readline library. You can check that with:
$ ldd $(which sqlite3)
In my case, I found out that the sqlite3 command was actually using the sqlite3 version in the installed Android SDK, by running:
$ which sqlite3
/opt/google/android-sdk/tools/sqlite3
That version does not have the readline library link, while the /usr/bin/sqlite3 one does. So what I did is move sqlite3 in the Android SDK out of the way (I still want to be able to access my other tools in that directory - but then I'd better make symlinks from /usr/local/bin or ~/bin), and running sqlite3 now uses the /usr/bin/sqlite3 one with readline linked into the executable, and the up/down arrow keys will work in there.