开发者

SQLite Clearing Database Question

开发者 https://www.devze.com 2023-02-01 00:12 出处:网络
I\'m trying to update the data in my SQLite database on iPhone. I\'d like to开发者_高级运维 drop and recreate the table (it\'s not big), or just truncate it, but I can\'t seem to do that.

I'm trying to update the data in my SQLite database on iPhone. I'd like to开发者_高级运维 drop and recreate the table (it's not big), or just truncate it, but I can't seem to do that.

Running

char *errorMsg;
    NSString *truncSQL = @"TRUNCATE TABLE GAMES;";
    if (sqlite3_exec(database, [truncSQL UTF8String], NULL, NULL, &errorMsg) != SQLITE_OK){
        NSLog(@"Error: %s", errorMsg);
        NSLog(truncSQL);
    }

gives me a database is locked error. There shouldn't be any active reads or anything from the database. How do I get it to do this?

Thanks!


Sometimes older versions of SQLite will give a "database locked" error if the file [DATABASE].journal exists. If you are sure nothing is accessing the database, try deleting that file.


Whoops, that was stupid.

Figured it out!

Accidentally missed a sqlite3_finalize(); statement somewhere!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号