I'm looking for a way to insert ~200 rows in a database efficiently, using the android shell exclusively.
The relevant part of the script I'm using is:
while read line
do
uid=`echo $line " awk '{print($2)}'`
pkg=`echo $line " awk '{print($1)}'`
/system/xbin/sqlite3 /mnt/sdcard/apps.db "INSERT INTO app_list values($uid, '$pkg', 0, 0, 0, 0, 0, 0)
done < /data/system/packages.list
The goal of this script is to generate a database containing a list of all installed apps (UID/Package name). The other columns are to be used later.
For ~200 apps, this script takes a few minutes: every sqlite command takes ~2 seconds to execute. This should be greatly improved by using transactions, but I see no clear way to do that.
Any help would be greatly appreciated,
Thanks.
EDIT:
In response to post #1:
Changed:
qry=$qry ($uid, '$pkg', 0, 0, 0, 0, 0, 0),
to qry=$qry" ($uid, '$pkg', 0, 0, 0, 0, 0, 0),"
and /system/xbin/sqlite3 /mnt/sdcard/apps.db $qry
to /system/xbin/sqlite3 /mnt/sdcard/apps.db "$qry;"
Echoing the last command shows:
/system/xbin/sqlite3 /mnt/sdcard/apps.db INSERT INTO app_list VALUES (10028, 'com.google', 0, 0, 0, 0, 0, 0), (10048, 'com.google.something', 0, 0, 0, 0, 0, 0), ... (10062, 'com.google.somethingelse', 0, 0, 0, 0, 0, 0);
Which seems correct, but outputs the following error when executed:
SQL error: near ",": syntax error