COUNT=$(sqlite3 "$db" "SELECT COUNT(*) FROM foo WHERE baz='$BAZ'") should totally work (I quoted $BAZ as a string, don't do that if it is a number, and you should escape any ' in $BAZ).
On Wed, Nov 9, 2016 at 11:40 AM Clemens Ladisch <clem...@ladisch.de> wrote: > Luca Ferrari wrote: > > 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'` > > You did not mention the shell, but double quotes should work. > > > Regards, > Clemens > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users