This I suppose follows on from my previous thread:

The data associated with this previous thread I am storing in an SQLite database.

I have sort of got it working using the command line SQLite interface.

but I was looking for something slicker and I stumbled across FMDB a Cocoa wrapper for SQLite.

It can be found here:

I have converted the ASOC code to Objective-C and this wrapper runs really well.

I have tried integrating it into ASOC but I cannot get it to work. It must be my misunderstanding on how to do it.

Has anybody here tired using FMDB with ASOC successfully and could they tell me how to integrate it please.




Just an update. I think it works.

This short snippet creates a database and then a table:

property pDBase : missing value

set pDBase to FMDatabase's databaseWithPath_(pDBPath)

if pDBase's |open|() as boolean = true then
pDBase's setShouldCacheStatements_(true)
pDBase's executeUpdate_("create table transactions (date double, type text, description text, amount double, category text)")
end if

It looks like this will work and it seems better than using this arrangement:

do shell script tHead & tSQLStatement & tTail

I will play further but better yet if someone has already implemented this.

All the best



Some more into.

I think this FMDB Cocoa SQLite wrapper is a better solution than the do shell arrangement.

Please take a look at this script:

	on addTransactionList_toTableName_inDB_(tTransactionList, tTableName, tDBase)
		repeat with tRecord in tTransactionList
			set tTransactionType to tRecord's objectAtIndex_(0)
			set tDatePosted to tRecord's objectAtIndex_(1)
			set tTransactionDate to dateFromString_(tDatePosted)
			set tTransactionAmount to NSNumber's numberWithFloat_(tRecord's objectAtIndex_(2)'s floatValue)
			set tTransactionUniqueID to tRecord's objectAtIndex_(3)
			set tTransactionName to tRecord's objectAtIndex_(4)
			tDBase's beginTransaction
			tDBase's executeUpdate_("insert into transactions (date, type, description, amount) values (?, ?, ?, ?)", tDatePosted, tTransactionType, tTransactionName, tTransactionAmount)
			tDBase's commit
		end repeat
	end addTransactionList_toTableName_inDB_

It takes a tTransactionList (NSArray)
a tTableName (NSString)
and a tDBase reference to a FMDatabase created or opened see earlier post.

tTransactionType is an NSString
tTransactionDate is an NSDate
tTransactionAmount is an NSNumber created from a NSString
tTransactionUniqueID is an NSString
tTransactionName is an NSString

I am just working my way through this Cocoa wrapper class but am enthusiastic about it’s use from within ASOC and would encourage others to review it.

All the best