gpt4 book ai didi

iphone - 添加 SQLcipher sqlite3_exec 后返回 SQLITE_NOTADB

转载 作者:搜寻专家 更新时间:2023-10-30 20:20:34 27 4
gpt4 key购买 nike

我将 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);
}

无法解决问题,我哪里出错了....

谢谢,

最佳答案

从邮件列表交叉发布:

I noticed in your code that you are only entering the block to sqlite3_open if the database file exists. Are you by chance trying to encrypt an existing standard SQLite database using SQLCipher using this code? If so, calling sqlite3_key will not work that way. You'd instead want to open the standard SQLite database, attach a new encrypted database, and then export the data between the two. There are some more details on this procedure here:

http://sqlcipher.net/sqlcipher-api/#sqlcipher_export

Once you're dealing with an encrypted database you can call sqlite3_key as the first operation before using it.

关于iphone - 添加 SQLcipher sqlite3_exec 后返回 SQLITE_NOTADB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12600668/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com