Running SQL via Manager

0 views
Skip to first unread message

Hunter Hillegas

unread,
Mar 12, 2009, 11:46:45 AM3/12/09
to sqlitepersiste...@googlegroups.com
I'm trying to run some 'cleanup' SQL through the shared manager
instance, like this:

SQLiteInstanceManager *manager = [SQLiteInstanceManager sharedManager];

int hourLimit = 36; //36 hours ago
double seconds = abs((hourLimit * 60 * 60));
NSDate *pastDate = [[NSDate date] addTimeInterval:seconds];
double pastDateInSeconds = [pastDate timeIntervalSince1970];

if ([manager tableExists:@"wave"])
[manager executeUpdateSQL:[NSString stringWithFormat:@"DELETE FROM
wave WHERE measured_at < %.0f", pastDateInSeconds]];

It's sorta verbose but you get the idea. Ideally I'd spawn a thread
and run this there but for now, it's just running as the last thing
after the app finishes startup.

This crashes, every time, though without any helpful error message.
Just straight up dies and dumps me into non-symbolicated code in the
debugger.

Any ideas? The 'wave' table does indeed exist. Am I just doing this
wrong? This was cribbed out of that presentation that Jeff posted. Any
help appreciated.

Cheers,
Hunter

Ken

unread,
Mar 12, 2009, 11:55:04 AM3/12/09
to sqlitepersistentobjects-user
Sometimes it's the little things... Do you need a trailing semicolon?
I don't recall precisely what SQLite's syntax says on that. Might be
worth a try. Otherwise, I'd try constructing your query on the line
before you attempt to execute it, so that you can see the query trying
to be run. Maybe it's not what you think it is, and is otherwise
malformed.

KM

Hunter Hillegas

unread,
Mar 12, 2009, 12:01:36 PM3/12/09
to sqlitepersiste...@googlegroups.com
Good thought but no dice - same deal.

If no one sees a blatant problem in what I'm trying to do, I'll
probably get into massive debugging mode and see if I can figure it out.
Reply all
Reply to author
Forward
0 new messages