litenoob wrote:
Hi, I'm wondering how to write a BASH script that will capture my SQLite
output.

I can do it for a single line with something like this:

somevar=`sqlite3 dbfilename "SELECT name FROM tablename WHERE name='smith'
LIMIT 1;"`

However, if I want to do anything with multiple lines, I haven't figured out
a good way.  So far, I'm using a workaround by outputting to a file, then
reading it after I exit the SQLite commandline, but that slows down the
script significantly.

e.g.

sqlite3 dbfilename << EOF

.output temp1
select id from tablename where name = "bush";
.output temp2
select id from tablename where name = "osama";

.quit
EOF

read id1 < temp1
read id2 < temp2

What's the better way to do this without actually writing to a file?

Thanks!

How about re-writing your query to generate shell script to set shell (or environment?) variables and using those variables in your script? Could you make the SQLite output look like shell script and execute or source that?

Or, use Tcl? ;)

Martin

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to