On 10 Oct 2013, at 3:02pm, John <sql...@johneday.com> wrote:

> Combining .commands does NOT work:
> 
> do shell script ("sqlite3 " & databasePath & " .separator \"||\" ; .import
> path/to/csv Main")
> ---------------------------------------------------------
> 
> Is my syntax wrong or can .commands not be included in a script?

You cannot combine commands in that way and call it that way.  They'd work 
separately but not together.

Instead, use AppleScript commands to write a text file.  Put all the commands 
you want in the text file including the one to set the separator and the one to 
read the .csv file.

Then start sqlite3 and tell it to execute that text file.  Something like

do shell script ("sqlite3 " & databasePath & " < commands.txt")

But actually you don't need to write two separate files: the .csv and the 
command file.  It might be better to instead make one file with proper import 
SQL commands in, and just tell sqlite3 to run that:

do shell script ("sqlite3 " & databasePath & " '.read importcommands.txt'")

that can have whatever sqlite3 commands you like in, including ones to create 
the table or delete any rows which already exist in it.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to