Re: Shell Scripting SQLite
Re: Shell Scripting SQLite
- Subject: Re: Shell Scripting SQLite
- From: Philip Aker <email@hidden>
- Date: Fri, 30 May 2008 06:30:31 -0700
On 08-05-30, at 06:05, BareFeet wrote:
Deviating from the OP's question, but prompted by part of your
message:
anything going back to AppleScript has to be ... or written to a
file that AppleScript then goes and reads.
I've been thinking about implementing this method for greater speed
when dealing with large results, such as displaying the output in a
table view in an Xcode project. It seems to me that we could
construct a shell script to output the results of select statement
to a file in a format that would suit a subsequent "read file ... as
list" AppleScript statement. That would eliminate the need for
AppleScript to do the laborious parsing of text into a list.
Something like:
set outputPath to "/tmp/SQLiteOutputForAppleScript
set sqlCommand to "select * from people;"
set mySeparator to "whatever AppleScript needs between list items in
a file"
do shell script "echo '.output " & outputPath & linefeed &
sqlCommand' | sqlite3 -separator " & (quoted form of mySeparator) "
& quoted form of myDBPath
...
set myAppleScriptList to read posix file outputPath as list
Does anyone know how this could be done so that the shell script
creates the file in a way that suits AppleScript reading it directly
in as a list?
I haven't tried this myself, but SQLite's "native" scripting interface
is in Tcl. I do know it's fairly simple to get Tcl to output in an
AppleScript list format for the return value. Also, Tcl has another
extension called Tclapplescript which can execute AppleScript directly
in the Tcl call.
Alternately, in the SQLite "shell.c" file, there is a switch for
output formats so you could add one to create an output AEListDesc
file easily in a custom executable. I have tweaked this file every
freakin' release just to get it to output lowercase HTML tags.
You can also use CoreData framework calls to pump directly into your
table views.
Philip Aker
echo email@hidden@nl | tr a-z@. p-za-o.@
Democracy: Two wolves and a sheep voting on lunch.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden