Cursor keys not working when using sqlite3 from adb shell

后端 未结 5 1229
伪装坚强ぢ
伪装坚强ぢ 2020-12-18 23:22

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

5条回答
  •  -上瘾入骨i
    2020-12-18 23:48

    Working off of Khanad's answer: I wrote a shell script on the device and I send my sqlite commands through it.

    First create a script file on the device and make it executable:

    # get on the device
    $ adb shell 
    
    # get write access on the device (this will also put you in the data/data directory)
    $ run-as com.YOUR_PACKAGE.YOUR_APP_NAME
    
    # create the script file
    $ touch qlite
    
    # make it executable
    $ chmod +x qlite
    

    Then add this code to the script. Remember to put your actual app name in there. (The echoes just add a little breathing room to the output.)

    echo
    
    sqlite3 databases/YOUR_APP_NAME -cmd ".mode column" ".headers on" "$1;"
    
    echo
    

    Then you just have to do something like:

    ./qlite "select * from table limit 1"
    

    The script will pass the sqlite command through, tack on the semi-colon, pretty print it with column names and you can use the up arrow to get your last command. And because you have write access you can make updates directly to the DB on the device.

    I hope this makes someone's life easier!

提交回复
热议问题