• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Shell Scripting Sqlite
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Shell Scripting Sqlite


  • Subject: Shell Scripting Sqlite
  • From: Bruce Robertson <email@hidden>
  • Date: Thu, 29 May 2008 16:03:35 -0700

With some success, I am experimenting with sqlite and shell scripts and
FileMaker.

However I'm trying to find a way do this more completely in memory using
variables

For instance posted further below is a script that gets a Filemaker record
set, creates an sqlite memory databases, sorts, captures unique values,
outputs as HTML. The script creates a long series of insert statements and
executes them as one transaction.

It works OK; but I want to try a few variations.

Goal 1 is to use the import command instead of the repeat loop to import the
data. But that requires writing the data to a text file. So---

Goal 2 is to be able to do the import using variables.



-- EXISTING SCRIPT - works OK

copy field "Company" of layout "Contacts" to companyList
set n to count of companyList
set applescript's text item delimiters to return
set shell_cmd to "sqlite3 -html  :memory: \"BEGIN TRANSACTION; create table
companies( company);"
set cmdlist to {}

-- construct insert commands
repeat with k from 1 to n
 set thisValue to quoted form of item k of companyList
 copy "INSERT INTO companies  values (\\\"" & item k of companyList &
"\\\"); " to end of cmdlist
end repeat

set shell_cmd to (shell_cmd & cmdlist as text) & "End Transaction; Select
company, count(company) as x from companies group by company order by x
desc, company asc;\""

do shell script shell_cmd
set thisResult to result as text
copy "<table>" & thisResult & "</table>" to cell "AS_Result" of current
record


-- result

<table><TR><TD>Microsoft Corporation</TD>
<TD>13</TD>
</TR>
<TR><TD>Adobe</TD>
<TD>10</TD>
</TR>
etc

 _______________________________________________
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

  • Follow-Ups:
    • Re: Shell Scripting Sqlite
      • From: Bruce Robertson <email@hidden>
  • Prev by Date: Re: Is there a list of known bugs in Keychain Scripting?
  • Next by Date: Re: Shell Scripting Sqlite
  • Previous by thread: Re: Help
  • Next by thread: Re: Shell Scripting Sqlite
  • Index(es):
    • Date
    • Thread