Hi all,
this could be trivial, but assuming I need some shell script to query
SQLite3 databases with variable-interpolated queries, what can I do?
Of course the following does not work because ticks prevent variable
interpolation:

COUNT=`sqlite3 $db 'SELECT COUNT(*) FROM foo WHERE baz=$BAZ'`

and the only ugly solution I thought is to use a temp file to write
down the query:

echo "SELECT COUNT(*) FROM foo WHERE baz=$BAZ" > $$.sql
COUNT=`sqlite3 $db < $$.sql`

but I'm sure there's a better and much more elegant approach.

Thanks,
Luca
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to