我正在使用 sqlite 数据库来存储我的数据。但是在插入查询时它显示“数据库已锁定”的错误。这是我的代码
sqlite3_stmt *statement;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
const char *dbpath = [[defaults objectForKey:@"dbpath"] UTF8String];
if (sqlite3_open(dbpath, &studentDB22) == SQLITE_OK)
{
NSString *insertSQL = [NSString stringWithFormat:@"INSERT INTO Emotion_videos (name) VALUES (\"%@\")",filePath];
const char *query_stmt = [insertSQL UTF8String];
if (sqlite3_prepare_v2(studentDB22, query_stmt, -1, &statement, NULL) == SQLITE_OK)
{
NSLog(@"shi h2345");
if (sqlite3_step(statement) == SQLITE_ROW)
{
printf( "could not prepare statement: %s\n", sqlite3_errmsg(studentDB22));
}
}
sqlite3_finalize(statement);
}
else
{
printf( "could not prepare statement: %s\n", sqlite3_errmsg(studentDB22));
}
我可以插入数据两到三次,但是当它再次运行时,它显示数据库锁定错误。