我将SQLCipher配置为他们网站中的教程...我可以编译&运行该项目。 但是sqlite3_exec在尝试执行语句时返回SQLITE_NOTADB。
请在下面找到代码段:
=================
NSString *dbPath = [self getDBPath];
BOOL success = [fileManager fileExistsAtPath:dbPath];
if(success) {
int sql_results = sqlite3_open([dbPath UTF8String], &SQLDB);
const char* key = [@"BIGSecret" UTF8String];
sqlite3_key(SQLDB, key, strlen(key));
if (sql_results == SQLITE_OK) {
NSString *sql;
const char *update_sql;
sql = [NSString stringWithFormat:@"DROP table %@",tablename];
update_sql = [sql cStringUsingEncoding:NSUTF8StringEncoding];
if(sqlite3_exec(SQLDB, update_sql, nil, nil, nil) == SQLITE_OK) {
NSLog(@"Good to go %@ dropped",tablename);
}
else {
NSLog(@"Bad Delete Cat SQL: %s -- %d", update_sql,sql_results);
NSLog(@"error code %i", sql_results);
}
我无法解决问题,我出错了......
谢谢,
本
答案 0 :(得分:2)
邮件列表中的交叉发布:
我在你的代码中注意到你只是进入了块 如果数据库文件存在,则为sqlite3_open。你是不是偶然想要 使用SQLCipher加密现有的标准SQLite数据库 这段代码?如果是这样,调用sqlite3_key将无法正常工作。你 而是想打开标准的SQLite数据库,附上一个新的 加密数据库,然后在两者之间导出数据。那里 这里有关于此程序的更多细节:
http://sqlcipher.net/sqlcipher-api/#sqlcipher_export
在您处理加密数据库后,您可以致电 sqlite3_key作为使用它之前的第一个操作。