I use the FMDatabase wrapper for SQLite3 in my OSX application. I introduce a lot of database attachments:
FMResultSet *results;
results= [db executeQuery:@"select count(*) from `items` where key = ?",[keyPath lowercaseString],nil];
while([results next])
{
if([results unsignedLongLongIntForColumnIndex:0]>0){
updateOperation=TRUE;
}
}
[results close];
if(updateOperation){
[db executeUpdate:@"update `items` set OSXsize=?,OSXOsize=?, OSXDate=?, UUID=?,sourceFile=?,tombStone=0,SandBoxBookMark=?,songname=?,albumartist=? where key=?",
size,originalSize, convertedDate,UUID,sourcePath,bookmark,fileName,albumArtist,[keyPath lowercaseString] , nil];
}
else
{
[db executeUpdate:@"insert into `items`(key,filepath, OSXsize, OSXOsize, OSXdate,UUID,sourceFile,tombStone,SandBoxBookMark,songname,albumartist) values(?,?,?,?,?,?,?,0,?,?,?)",
[keyPath lowercaseString], dapPath, size,originalSize, convertedDate,UUID,sourcePath,bookmark,fileName,albumArtist, nil];
}
I open the database once, however I see that 4725 + handlers are attached when the application is running in the activity monitor:
/Users/userA/Library/Containers/com.map-pin.Dapper/Data/Library/Application Support/com.map-pin.Dapper/dapperright.sqlite
15
16
...
4724
4725