On 17/10/2006, at 9:31 PM, Martin Jenkins wrote:

Does the SQL output work for your application? Might be just as easily parseable as yet-another-version-of-CSV...

I originally dismissed the sql "insert" output mode as most likely having the same bug as csv. Upon checking, however, the insert mode seems to work perfectly, handling commas and returns/linefeeds within quotes, as well as substituting a quote within a quote with a double quote.

It works the way that CSV should (which needs fixing). I can use a slightly modified CSV parsing handler, by just using this as the row separator (instead of just plain linefeed):

");<linefeed>INSERT INTO <tableName> VALUES("

For example:

CREATE TABLE Test( field1 );
INSERT INTO "Test" VALUES('I said "Hi there"');
INSERT INTO "Test" VALUES("I said 'all you'");
INSERT INTO "Test" VALUES('I said ''SQLite
people''');
.mode insert
SELECT * FROM Test;

which gives:

INSERT INTO table VALUES('I said "Hi there"');
INSERT INTO table VALUES('I said ''all you''');
INSERT INTO table VALUES('I said ''SQLite
people''');

which parses to give 3 records:

I said "Hi there"

I said 'all you'

I said 'SQLite
people'

Great :-)

For those who asked, I'm building an application using "AppleScript Studio", which is basically Apple's Xcode development environment, using AppleScript as the programming language. SQLite is built into Mac OS X, and can be called via shell scripts. Within AppleScript, this looks something like:

do shell script "sqlite3 Test.sqlite 'CREATE TABLE Test( field1 );'"

If anyone knows how to instead directly (ie not via a shell script) call the SQLite routines in Mac OS X, I'm all ears :-)

Thanks,
Tom


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

Reply via email to