Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cursor keys not working when using sqlite3 from adb shell

When using sqlite3 through adb shell arrow keys, instead of moving the cursor to the desired position or summoning the history facility, the following is showed in the screen: ^[[A, ^[[B, ^[[C, ^[[D.

I'm using Mac OS X and I have tried Terminal and iTerm terminal emulators.

Does anybody know how to fix this?

like image 543
Tanausú González Avatar asked Apr 01 '13 16:04

Tanausú González


3 Answers

You can use the previous command functionality in the adb shell. So just adb shell. Then cd to the /data/data//databases directory. From here run (for example): sqlite3 "select * from "

Then you can use up arrow to redo that command. Kind of a hack, but way better than having to retype the command inside the sqlite3 interactive prompt.

like image 169
Khanad Avatar answered Nov 17 '22 03:11

Khanad


A workaround would be to use a local version of SQLite with readline support.

  1. Copy a database file from your device to your local machine:
    adb pull <database-file-on-device>

  2. Use your local version of SQLite to access the database file:
    sqlite3 <database-file-on-local>

  3. If you made changes you can transfer them to the device. Copy your local database file from your local machine to your device:
    sqlite3 <database-file-on-local> <database-file-on-device>

like image 38
chobok Avatar answered Nov 17 '22 02:11

chobok


To allow editing and history in the input of a console program, that program must be linked with the readline library.

The sqlite3 tool does support readline, but on Android, readline support has been disabled. (Probably because readline is licensed only under the GPL.)

like image 6
CL. Avatar answered Nov 17 '22 04:11

CL.