On page 18 of the book "SQLite" by Chris Newman, he states "... it is
possible to pipe or redirect a series of commands to the program
rather than key them in"
I'm trying to get this to work using the shell, and cannot seem to do
it. Once I get it working then I can call them as shown below in the
"do shell script..." code below
I tried finding a pragma command for .headers on, but didn't have any
luck.
sqlite> .headers on | .mode column customers | select * from customers ;
I also tried :
sqlite> select * from customers ; < .headers off
and that didn't work either
The reason I am trying to do this in one call rather than using
multiple lines is that one "do shell script" call is totally
independent from the next, unlike scripting to a shell window which I
don't want to do.
sqlite> .headers on
sqlite> .mode column customers
sqlite> select * from customers ;
is that I am calling it from Applescript, and one "do shell script"
to sqlite doesn't have a clue what the previous one did.
do shell script "sqlite3 ~/desktop/TestDB.db " & ".headers on"
do shell script "sqlite3 -column ~/desktop/TestDB.db " & quote &
thisQuery & quote)
I realize that I am trying to mix dot commands with sql commands, but
there doesn't seem to be a pragma for the headers
so I could do something like :
sqlite> pragma set_headers("on") ; select * from customers ;
Which I could then convert to :
do shell script "sqlite3 -column ~/desktop/TestDB.db " & quote &
pragma set_headers("on") ; select * from customers ; & quote)
handler snippet :
on run
set thisTable to "customers"
set searchField to "lastname"
set searchValue to "somevalue"
set sortField to "firstname"
set sortDir to "asc"
set whichChoice to "contains"
my sqlite_DoTheSearch(whichChoice, thisTable, searchField,
searchValue, sortField, sortDir)
end run
on sqlite_DoTheSearch(whichChoice, thisTable, searchField,
searchValue, sortField, sortDir)
... missing lines here
else if (whichChoice = "contains") then
set thisQuery to "select * from " & thisTable & " where " &
searchField & " LIKE '%" & searchValue & "%' order by " & sortField &
" " & sortDir & ";"
... missing lines here
display dialog ("QUERY : " & quote & thisQuery & quote & return &
return & (do shell script "sqlite3 -column ~/desktop/TestDB.db " &
quote & thisQuery & quote))
end sqlite_DoTheSearch
I'd be grateful for any insights...
Bill Hernandez
Plano, Texas
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------