简体   繁体   中英

Errors running sqlite through adb shell

Running from the command-line on a Windows 10 PC, and I'm having a problem with quotation marks:

  • adb shell su -c "sqlite3 /data/data/com.android.chrome/app_chrome/Default/Cookies 'select count(*) from cookies;'"
    • sush: syntax error: '(' unexpected
  • adb shell su -c sqlite3 /data/data/com.android.chrome/app_chrome/Default/Cookies 'select count(*) from cookies;'
    • sush: syntax error: '(' unexpected
  • adb shell su -c sqlite3 /data/data/com.android.chrome/app_chrome/Default/Cookies "select count(*) from cookies;"
    • /system/bin/sh: syntax error: '(' unexpected
  • I tried a query which didn't contain parens, but that wouldn't run either:
    • adb shell su -c "sqlite3 /data/data/com.android.chrome/app_chrome/Default/Cookies 'select * from cookies;'"
      • Error: near "select": syntax error
  • I can run other sqlite3 commands from the adb shell
    • adb shell su -c "sqlite3 /data/data/com.android.chrome/app_chrome/Default/Cookies .schema"
      • that works with or without quotation marks.

And going into ADB shell works:

>adb shell
/ $ su
/ # sqlite3 /data/data/com.android.chrome/app_chrome/Default/Cookies 'select count(*) from cookies;'
3238

I simply want to get the results of a query from the command-line.
What am I missing?

Try this:

adb shell su -c sqlite3 /data/data/com.android.chrome/app_chrome/Default/Cookies "\"select count(*) from cookies;\""

or

query="\"select count(*) from cookies;\""
adb shell su -c sqlite3 /data/data/com.android.chrome/app_chrome/Default/Cookies "$query"

I guess the problem is with the double quotes. I am still not quite sure why those double quotes are needed within the query, but this is most certainly to work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM