在这里,我想使用两个数据库执行查询并将数据从 database1 的表复制到另一个 database2。在这里我可以打开一个数据库,但在打开其他数据库时遇到问题。在此先感谢大家。
CurrentStatus *status = [CurrentStatus sharedCurrentStatus];
sqlite3 *database;
sqlite3 *database1;
sqlite3_stmt *statement;
sqlite3_stmt *statement1;
NSString *dbPath = [status.applicationDocumentDirectory stringByAppendingPathComponent:@"database.sqlite"];
NSString *dbPath1 = [status.applicationDocumentDirectory stringByAppendingPathComponent:@"database1.sqlite"];
if ((sqlite3_open_v2([dbPath UTF8String], &database, SQLITE_OPEN_READWRITE , NULL) == SQLITE_OK) && (sqlite3_open_v2([dbPath1 UTF8String], &database1, SQLITE_OPEN_READWRITE , NULL) == SQLITE_OK)) {
NSString *sqlStr = [[NSString alloc] initWithFormat:@"select * from Login" ];
NSString *sql = [[NSString alloc] initWithString:sqlStr];
if ((sqlite3_prepare_v2(database, [sql UTF8String], -1, &statement, NULL) == SQLITE_OK)) {
NSLog(@"DB prepare_v2 Opening successfully");
if (sqlite3_step(statement) == SQLITE_ROW) {
}
else
{
}
sqlite3_finalize(statement);
NSLog(@"DB Opening successfully");
sqlite3_close(database);
}else
{
NSLog(@"else DB Opening successfully");
}
sqlite3_close(database);
}